I am trying to set an automatically generated coupon code to a Magento 2 quote.
I am using is:
$this->_checkoutSession->getQuote()->setCouponCode($post['coupon_code'])->setTotalsCollectedFlag(false)->collectTotals()->save();
The coupon code is being set in the quote but it is not updating when redirected by to the Magento cart page
Solved! Go to Solution.
My original code worked with a single coupon code but not with multiple generated codes. I have resolved this by copying the couponPost controller from Magento_Checkout into my module and make the necessary changes.
My original code worked with a single coupon code but not with multiple generated codes. I have resolved this by copying the couponPost controller from Magento_Checkout into my module and make the necessary changes.