diff --git a/packages/Webkul/Discount/src/Helpers/Discount.php b/packages/Webkul/Discount/src/Helpers/Discount.php index b67d901fc..1b041ed7d 100644 --- a/packages/Webkul/Discount/src/Helpers/Discount.php +++ b/packages/Webkul/Discount/src/Helpers/Discount.php @@ -192,33 +192,6 @@ abstract class Discount return true; } - /** - * To find the least worth item in current cart instance - * - * @return array - */ - public function leastWorthItem() - { - $cart = Cart::getCart(); - - $leastValue = 999999999999; - $leastWorthItem = []; - - foreach ($cart->items as $item) { - if ($item->price < $leastValue) { - $leastValue = $item->price; - $leastWorthItem = [ - 'id' => $item->id, - 'price' => $item->price, - 'base_price' => $item->base_price, - 'quantity' => $item->quantity - ]; - } - } - - return $leastWorthItem; - } - /** * Update discount for least worth item */ @@ -269,6 +242,33 @@ abstract class Discount return true; } + /** + * To find the least worth item in current cart instance + * + * @return array + */ + public function leastWorthItem() + { + $cart = Cart::getCart(); + + $leastValue = 999999999999; + $leastWorthItem = []; + + foreach ($cart->items as $item) { + if ($item->price < $leastValue) { + $leastValue = $item->price; + $leastWorthItem = [ + 'id' => $item->id, + 'price' => $item->price, + 'base_price' => $item->base_price, + 'quantity' => $item->quantity + ]; + } + } + + return $leastWorthItem; + } + /** * To find the max worth item in current cart instance * diff --git a/packages/Webkul/Discount/src/Helpers/NonCouponAbleRule.php b/packages/Webkul/Discount/src/Helpers/NonCouponAbleRule.php index 350f5622f..550b9f07c 100644 --- a/packages/Webkul/Discount/src/Helpers/NonCouponAbleRule.php +++ b/packages/Webkul/Discount/src/Helpers/NonCouponAbleRule.php @@ -165,7 +165,7 @@ class NonCouponAbleRule extends Discount } else { $this->save(array_first($maxImpacts)['rule']); - return $maxImpacts; + return array_first($applicableRules)['impact']; } } else { $this->save(array_first($prioritySorted)['rule']);