diff --git a/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php b/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php index 4daeb90be..4b9fc7f4a 100644 --- a/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php +++ b/packages/Webkul/Discount/src/Actions/Cart/FixedAmount.php @@ -56,9 +56,9 @@ class FixedAmount extends Action $report['item_id'] = $item->id; $report['product_id'] = $item->child ? $item->child->product_id : $item->product_id; - $discount = round($itemPrice * $discQuantity, 4); + $discount = round($itemPrice * $discQuantity, 4) * $discQuantity; - $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 46343b847..ce776ef7c 100644 --- a/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php +++ b/packages/Webkul/Discount/src/Actions/Cart/PercentOfProduct.php @@ -63,9 +63,15 @@ class PercentOfProduct extends Action $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); + if ($rule->disc_amount > 100) { + $discount_amount = 100; + } else { + $discount_amount = 100; + } - $discount = $discount <= $itemPrice ? $discount : $itemPrice; + $discount = round(($itemPrice * $discount_amount) / 100, 4) * $discQuantity; + + $discount = $discount <= $itemPrice * $discQuantity ? $discount : $itemPrice * $discQuantity; $report['discount'] = $discount; diff --git a/packages/Webkul/Discount/src/Helpers/Cart/Discount.php b/packages/Webkul/Discount/src/Helpers/Cart/Discount.php index d2b7b3cec..5488de48e 100644 --- a/packages/Webkul/Discount/src/Helpers/Cart/Discount.php +++ b/packages/Webkul/Discount/src/Helpers/Cart/Discount.php @@ -58,16 +58,16 @@ abstract class Discount */ public function getApplicableRules($code = null) { + $rules = collect(); + if ($code != null) { - $rules = $this->cartRule->findWhere([ + $eligibleRules = $this->cartRule->findWhere([ 'use_coupon' => 1, 'status' => 1 ]); - foreach($rules as $rule) { + foreach($eligibleRules as $rule) { if ($rule->coupons->code == $code) { - $rules = collect(); - $rules->push($rule); break;