Apply discount not seen in docs #1545
-
What is the method to apply discounts?
The discount column is updating in the database but when I dump the $cart, no discount is applied. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The Discount Manager caches the discounts per request, so if you're doing something to the cart that will affect the discounts (like applying a coupon code), you will want to reset the discounts. E.g. $discount = $this->coupon_code;
if (Discounts::validateCoupon($discount)) {
$this->cart->coupon_code = $discount;
$this->cart->save();
Discounts::resetDiscounts();
} |
Beta Was this translation helpful? Give feedback.
-
Recalculate the cart $this->cart->calculate(); |
Beta Was this translation helpful? Give feedback.
-
Thank you guys. Works as a charm! Appreciate your help. |
Beta Was this translation helpful? Give feedback.
The Discount Manager caches the discounts per request, so if you're doing something to the cart that will affect the discounts (like applying a coupon code), you will want to reset the discounts.
E.g.