More refactoring of discount assign to cart item
This commit is contained in:
parent
9c23179d6e
commit
5e47c5b2af
|
|
@ -51,12 +51,6 @@ class FixedAmount extends Action
|
|||
|
||||
$discQuantity = $itemQuantity <= $discQuantity ? $itemQuantity : $discQuantity;
|
||||
|
||||
if ($rule->disc_amount >= $itemPrice) {
|
||||
$discount = round($itemPrice * $discQuantity, 4);
|
||||
} else {
|
||||
$discount = $rule->disc_amount;
|
||||
}
|
||||
|
||||
$totalDiscount = $totalDiscount + $discount;
|
||||
|
||||
$report = array();
|
||||
|
|
@ -64,11 +58,11 @@ class FixedAmount extends Action
|
|||
$report['item_id'] = $item->id;
|
||||
$report['product_id'] = $item->child ? $item->child->product_id : $item->product_id;
|
||||
|
||||
if ($discount <= $itemPrice) {
|
||||
$report['discount'] = $discount;
|
||||
} else {
|
||||
$report['discount'] = $itemPrice;
|
||||
}
|
||||
$discount = round($itemPrice * $discQuantity, 4);
|
||||
|
||||
$discount = $discount <= $itemPrice ? $discount : $itemPrice;
|
||||
|
||||
$report['discount'] = $discount;
|
||||
|
||||
$report['formatted_discount'] = core()->currency($discount);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ class PercentOfProduct extends Action
|
|||
|
||||
$discQuantity = $itemQuantity <= $discQuantity ? $itemQuantity : $discQuantity;
|
||||
|
||||
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
|
||||
|
||||
$report = array();
|
||||
|
||||
$report['item_id'] = $item->id;
|
||||
$report['product_id'] = $item->child ? $item->child->product_id : $item->product_id;
|
||||
|
||||
$discount = round(($itemPrice * $rule->disc_amount) / 100, 4);
|
||||
|
||||
$discount = $discount <= $itemPrice ? $discount : $itemPrice;
|
||||
|
||||
$report['discount'] = $discount;
|
||||
|
|
|
|||
Loading…
Reference in New Issue