Skip to content

Instantly share code, notes, and snippets.

@bennick
Created December 12, 2013 01:05
Show Gist options
  • Save bennick/7921553 to your computer and use it in GitHub Desktop.
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.
<?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