Customised commission amount per user

2 replies [Last post]
aidan
Offline
Joined: 10/28/2009
Status: 
Answered

I need customised commissions based on the user. The way I have it set up, the users have a profile field which contains their commission level.

We can achieve this with your module by adding a hook, to line 614 of paypal_affiliates.module

      //Get the Commission to pay for this level
      $commission = round(paypal_affiliates_get_commission($level, $amount), 2);

      foreach (module_implements('paypal_affiliates_commission') as $module) {
        $hook = $module . '_paypal_affiliates_commission';
        $hook($commission, $level, $amount, $aAccount);
      }

This lets any other contrib modules play with the commission, my function for example:

/**
 * Implements hook_paypal_affiliates_commission().
 *
 * Works out a custom commission value based on the users profile
 */
function example_paypal_affiliates_commission(&$commission, $level, $amount, $account) {
  profile_load_profile($account);
  if (!empty($account->profile_commission)) {
    $commissions = explode(',', $account->profile_commission);
    $commission = ($commissions[$level-1]/100)*$amount;
  }
}

 

This is a pretty lightweight change to your module but opens up a whole array of customisations, any chance it could be included in the next version?

 

Leighton Whiting
Online
Joined: 06/02/2009
Aidan, I love it, I'll add it

Aidan,
I love it, I'll add it in to the next release.

Sincerely,
Leighton Whiting

Leighton Whiting
Online
Joined: 06/02/2009
Aidan, I have added it, but

Aidan,
I have added it, but the Paypal Affiliates module has a newer version out than what you are using, so there were a few differences, but the end result will be the same. The difference is that Subscription Plans, Node Plans, File Plans, and other things can specify 'Custom Commission Levels' on a per-product basis.

Sincerely,
Leighton Whiting

Twitter Feed