cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic shopping cart price rule does not apply if coupon code is applied

SOLVED

Automatic shopping cart price rule does not apply if coupon code is applied

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

6x certified Magento Specialist.
Nigel Boulton, Magento Solution Specialist
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Automatic shopping cart price rule does not apply if coupon code is applied

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. 

6x certified Magento Specialist.
Nigel Boulton, Magento Solution Specialist

View solution in original post

1 REPLY 1

Re: Automatic shopping cart price rule does not apply if coupon code is applied

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. 

6x certified Magento Specialist.
Nigel Boulton, Magento Solution Specialist