18 require_once dirname(__FILE__).
'/../../promotional_rule/promotional_rule.inc';
42 parent::__construct($assetid);
56 'fixed_amount' =>
'Fixed Amount',
57 'percentage' =>
'Percentage',
71 return 'fixed_amount';
92 'discount_options' => Array(),
109 $price = $asset_data[
'price'];
110 $remaining_quantity = $asset_data[
'quantity'];
113 $discount_options = $rule_data[
'discount_options'];
114 $fixed_amount = $rule_data[
'discount_type'] ==
'fixed_amount' ? TRUE : FALSE;
115 $discount_options = array_reverse($discount_options, TRUE);
116 foreach ($discount_options as $asset_quantity => $discount_amount) {
117 if ($remaining_quantity >= $asset_quantity) {
118 $quotient = (int) ($remaining_quantity / $asset_quantity);
119 $remaining_quantity = $remaining_quantity % $asset_quantity;
121 $discount += $quotient * $discount_amount;
123 $discount += $quotient * ($asset_quantity * $price * $discount_amount / 100);
126 if ($remaining_quantity == 0)
break;
130 $asset_data[
'discount'] = $discount;