diff --git a/packages/Webkul/Discount/src/Helpers/Discount.php b/packages/Webkul/Discount/src/Helpers/Discount.php index c5bb028dc..cae8eb6ba 100644 --- a/packages/Webkul/Discount/src/Helpers/Discount.php +++ b/packages/Webkul/Discount/src/Helpers/Discount.php @@ -114,6 +114,18 @@ class Discount if ($canBeApplied->count()) { $this->save(array_first($canBeApplied)['rule']); + $itemId = array_first($canBeApplied); + + foreach (\Cart::getCart()->items as $item) { + if ($item->id == $itemId['item_id']) { + $item->update([ + 'discount_amount' => array_first($canBeApplied)['discount'], + 'base_discount_amount' => array_first($canBeApplied)['discount'] + ]); + + break; + } + } return array_first($canBeApplied); } else { @@ -307,6 +319,7 @@ class Discount } } + $report['item_id'] = $leastWorthItem['id']; $report['discount'] = $amountDiscounted; $report['formatted_discount'] = core()->formatPrice($amountDiscounted, $cart->cart_currency_code); $report['new_grand_total'] = $cart->grand_total - $amountDiscounted; diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index f1a0662b5..de749c49f 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -90,6 +90,8 @@ class OnepageController extends Controller if (Cart::hasError() || !Cart::saveCustomerAddress($data) || ! $rates = Shipping::collectRates()) return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403); + $rule = Cart::applyNonCoupon(); + Cart::collectTotals(); return response()->json($rates); @@ -107,6 +109,8 @@ class OnepageController extends Controller if (Cart::hasError() || !$shippingMethod || !Cart::saveShippingMethod($shippingMethod)) return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403); + $rule = Cart::applyNonCoupon(); + Cart::collectTotals(); return response()->json(Payment::getSupportedPaymentMethods());