Relative Commission Formulas

My affiliates can provide customers with various discount coupons that are affiliate links to their account. I want to give them the maximum earned commission based on the base price I sell the product to them. This would mean I can’t set any flat RATE because the variation of the selling price could determine the final commission. So if I want them to have all the difference between the price the product sold at and the wholesale price I sell it to them, how could Affiliate Enterprise Relative Commission formulas allow me to do this. Please respond urgently because I am behind schedule on this program. Thank you


Comments

One response to “Relative Commission Formulas”

  1. Hi,

    As a first consideration, if the coupon is applied to the order and related to the affiliate, the commission will be based on the net amount – if that is sufficient, then you could simply use a rate which will then result in a proportional commission amount credited to the affiliate, while automatically taking into account any discounts applied on the products and the order.

    If you would actually do some further adjustments, then you would need to adjust the referral amount once the referral has been created. We are working on additions which will be available in versions 4.x that allow to compute the value before the referral is created persistently. Alternatively, you could use a custom implementation following this approach:

    add_filter( 'affiliates_referral', 'my_affiliates_referral', 10, 2 );
    function my_affiliates_referral( $referral_id, $data ) {
        $referral = new Affiliates_Referral();
        if ( $referral->read( $referral_id ) ) {
            //  $referral->reference contains the order ID
            if ( $referral->referral_items !== null ) {
                foreach ( $referral->referral_items as $item ) {
                    // $item->reference contains the order item ID
                    if ( $item->type === 'product' ) {
                        $product_id = $item->object_id;
                        $adjustments = 0; // @todo implement any adjustments needed here
                        $item->amount -= $adjustments;
                    }
                }
                $referral->compute(); // calculates the referral total
                $referral->update(); // saves the changes
            }
        }
    }

    By coincidence, I just explained this approach in a very similar case – if you would like to take this approach, then you simply need to calculate the adjustments so that they are deducted from the line amount. If you would rather follow this up once the new releases are ready, please let me know and we can use the additions to apply a solution for your case.

    Cheers

Share