Description
Retrieves a commission from the database by the given ID.
Parameters
slicewp_get_commission( $commission );
$commission
(int)(required) The commission’s ID.
Return
(SliceWP_Commission|null) A SliceWP_Commission object containing the commission data, or null if data for the given commission ID doesn’t exist in the database.
Example
The following example shows how you can retrieve the data object for commission #767.
$commission = slicewp_get_commission( 767 );
// Returned value.
SliceWP_Commission Object
(
[id:protected] => 767
[affiliate_id:protected] => 77
[visit_id:protected] => 3814
[date_created:protected] => 2021-08-08 18:16:46
[date_modified:protected] => 2021-08-08 18:16:46
[type:protected] => sale
[status:protected] => unpaid
[reference:protected] => 121
[customer_id:protected] => 49
[origin:protected] => woo
[amount:protected] => 1.25
[parent_id:protected] => 0
[currency:protected] => USD
)
Because the SliceWP_Commission object’s properties are protected, to access them you can use the get( $property_name )
method.
$commission = slicewp_get_commission( 767 );
if ( ! is_null( $commission ) ) {
$affiliate_id = $commission->get( 'affiliate_id' );
$status = $commission->get( 'status' );
}