From 6ca065544cae21350ca701e9568a0ad6a368564a Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Fri, 6 Sep 2019 13:46:20 +0530 Subject: [PATCH] Edge case fix for Cart Rule actions --- packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php | 4 +--- .../Webkul/Discount/src/Actions/Cart/PercentOfProduct.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php b/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php index 668862df4..4b9fc7f4a 100644 --- a/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php +++ b/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php @@ -58,9 +58,7 @@ class FixedAmount extends Action $discount = round($itemPrice * $discQuantity, 4) * $discQuantity; - if ($rule->action_type == 'fixed_amount') { - $discount = $discount <= $itemPrice ? $discount : $itemPrice; - } + $discount = $discount <= $itemPrice * $discQuantity ? $discount : $itemPrice * $discQuantity; $report['discount'] = $discount; diff --git a/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php b/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php index b9f0e4574..ce776ef7c 100644 --- a/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php +++ b/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php @@ -71,9 +71,7 @@ class PercentOfProduct extends Action $discount = round(($itemPrice * $discount_amount) / 100, 4) * $discQuantity; - if ($rule->action_type == 'percent_of_product') { - $discount = $discount <= $itemPrice ? $discount : $itemPrice; - } + $discount = $discount <= $itemPrice * $discQuantity ? $discount : $itemPrice * $discQuantity; $report['discount'] = $discount;