1. Documentation /
  2. Affiliate For WooCommerce /
  3. How to calculate commission for custom order statuses

How to calculate commission for custom order statuses

Affiliate for WooCommerce helps add and manage affiliates and track performance from a single place – commissions, sales, payout, leaderboard, etc. Earn money without hard work. Increase your brand outreach, and get potential customers.

The Affiliate for WooCommerce plugin automatically marks commission status based on default order statuses as explained in this doc.

Note

The below method is considered customization. We are happy to provide guidance, but we are unable to provide support or help to suit your store. Only use it if you are comfortable with PHP and custom coding and troubleshooting on your own.

What if I have a custom order status?

↑ Back to top

Please check if your custom order status is in the list of order statuses that are considered ‘paid’ that is returned by the function wc_get_is_paid_statuses().

Kindly contact your developer or plugin support if you are unsure whether your custom order status is included.

If your custom order status is already included in the list, the commission status will automatically be marked as “Unpaid” for orders with that status, and you don’t need to use any additional code.

For the custom order statuses that are not included in that list, you can register it using Affiliate for WooCommerce’s filter. This will ensure that the commission status is automatically marked for orders with that status.

Set commission status as ‘Unpaid’ for your custom order statuses

↑ Back to top
add_filter( 'afwc_paid_order_statuses', 'sa_afwc_add_custom_order_status_into_paid_statuses' );
function sa_afwc_add_custom_order_status_into_paid_statuses ( $statuses = array() ) {
     if ( ! is_array( $statuses ) ) {
        return $statuses;
    }

    // Add custom order status to the array.
    $statuses[] = 'custom-order-status';

    return $statuses;
}

Set commission status as ‘Rejected’ for your custom order statuses

↑ Back to top
add_filter( 'afwc_rejected_order_statuses', 'sa_afwc_add_custom_order_status_into_rejected_statuses' );
function sa_afwc_add_custom_order_status_into_rejected_statuses( $statuses = array() ) {
    if ( ! is_array( $statuses ) ) {
        return $statuses;
    }

    // Add custom order status to the array.
    $statuses[] = 'custom-order-status';

    return $statuses;
}

You can securely add code snippets to your site using either of the methods mentioned here: How to properly add WooCommerce custom code.

Feature request

↑ Back to top

Have feature requests or enhancement suggestions for Affiliate For WooCommerce? Submit it from here: Submit a request or send it to us from here.