I'm running a web shop which includes an affiliate program.
I changed the total calculation so that the affiliates will only get payed for the product price. An exception for this was discounts, which were included into the calculation if existed. So affiliate calculation is always 'Product price - Discount'.
Now I've introduced payment fees into my system as well. Currently, my affiliates get a commission from the price including the payment fee, which kinda destroys its purpose. Would appreciate if someone can help me change the calculation so it wont include that.
Here is the sample of my code:
Code: Select all
if (isset($this->request->cookie['tracking'])) {
$this->load->model('affiliate/affiliate');
$affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);
$subtotal = $this->cart->getSubTotal();
if ($affiliate_info) {
$data['affiliate_id'] = $affiliate_info['affiliate_id'];
// $data['commission'] = ($subtotal / 100) * $affiliate_info['commission'];
$aff_total = $total;
foreach($taxes as $_v) {
$aff_total -= $_v;
}
$data['commission'] = ($aff_total / 100) * $affiliate_info['commission'];
} else {
$data['affiliate_id'] = 0;
$data['commission'] = 0;
}
} else {
$data['affiliate_id'] = 0;
$data['commission'] = 0;
}