Magento Tutorials

How to Solve “Coupon code is not valid” Error in Magento

Sometimes in Magento, the coupon codes that you set up stop working for no reason. There’s an error message saying “Coupon code xxx is not valid”. Our guide will provide several solutions to help you get your coupon codes working again.

How to Solve “Coupon code is not valid” Error

Disable Discard subsequent rules

Log into your Magento backend. Go to Marketing > Promotions > Cart Price Rules.

Magento 2 Cart Price Rules
  1. Under the Rule Information section, check Customer Groups to see if it is set correctly, or even been set at all. Normally you will want to enable it for “NOT LOGGED IN” customers. You can also try to enable it for all of the customer groups to see if the problem is still there. If after enabling all customer groups the problem still persists, move on to the next steps.
    Magento 2 rule information
  2. Under Conditions section, see if any condition exist. If there is any, check the logic to see if it prevents the coupon code from being applied.
    Magento 2 coupon conditions
  3. Under Actions section, notice the Discard subsequent rules. If it is set to Yes then it is preventing other coupon codes from being applied. You may want to set it to No. Notice that this does not stop the current coupon code from happening, but other coupon codes. So if you are having problem on your current coupon code, you may want to check your other coupon codes and set Discard subsequent rules for all of them to No.
    Magento 2 coupon actions

Edit expiration date

If you’re using an older version of Magento (< 2.4.x), chances are this is an issue with the way that you set your coupon code’s expiration date. When the expiration date is set too high (> 20 years), it actually results in a reproducible bug which prevents your coupon code from being applied. 

To get around this, you’ll need to reduce your expiration date to a more sensible period, preferably less than 20 years difference between the From and the To fields.

Magento coupon code max expiration date

Add formkey to your coupon template

formkey is added in Magento 2.2.9 and it’s possible that your current coupon template lacks this block. To add formkey into your coupon template, you’ll first need to navigate to:


and inside the <form> element you’ll want to add:

<?= $block->getBlockHtml('formkey'); ?>

After this, reindex and clear your cache using:

php bin/magento indexer:reindex 
php bin/magento cache:flush

And check if the issue is resolved for you.

See also: Catalog Price Rules not working in Magento 2


A knowledge craver who always strive to be wiser everyday.

Notify of

Most Voted
Newest Oldest
Inline Feedbacks
View all comments
4 years ago

I’ve tried all of these things, applied to all customer groups, only condition is orders vale >15 and discard subsequent rules is turned to yes. When testing on a basket of £20 continues to say, Coupon Code not valid. Please Help!

4 years ago

Cant seem to get a code to work when a reorder is placed through a users past orders in account. Any ideas?

3 years ago

I have only 1 coupon code and I cannot seem to get it to work.

I am trying to give free shipping for products in a specific category, to anywhere within a certain province.

I followed this exactly and it doesn’t seem to work.

I get the error code “The coupon code “berettaday” is not valid.”

Please help!

5 years ago

Thank you! The first solution helped me.