Created
December 12, 2013 01:05
-
-
Save bennick/7921553 to your computer and use it in GitHub Desktop.
An example of how to adjust the commission for one specific item in a referral's order.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AbcStore_Module extends Core_ModuleBase | |
{ | |
public function subscribeEvents() | |
{ | |
Backend::$events->addEvent('threetwentynyaffiliate:onGetReferralCommission', $this, 'on_get_referral_commission'); | |
} | |
public function on_get_referral_commission($referral, $original_commission) | |
{ | |
$order = $referral->order; | |
$commission = $original_commission; | |
foreach($order->items as $item) { | |
if ($item->product->sku == 'your-product-sku') { | |
$old = $item->single_price * $referral->commission_percentage * .01; //Figure out old commission | |
$new = $item->single_price * .02; // Low 2% commission for this product | |
$commission -= ($old - $new); // Subtract the difference | |
} | |
} | |
return $commission; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment