Promotional code is an effective way to encourage shoppers to spend more as well as to retain their loyalty to your business. However, sometimes the codes stop working for no reason. An error message may pop up with “The promotional code you entered is not valid” in Magento 2.
There are 3 ways you can follow to make the coupon codes work again.
Edit Expiration Date
For those using an older Magento version (< 2.4.x), the issue may originate from the way the coupon code’s expiration date is set. If the expiration date is set higher than 20 years, then a reproducible bug will prevent the codes from being applied in the system. This is why you’ll see the message saying the code isn’t valid.
It’s easy to fix this as you can adjust the code’s expiration date to a closer time of fewer than 20 years of difference.
Disable Discard Subsequent Rules
Step 1: From the Admin panel, navigate Marketing > Promotions > Pricing Cart Rules.
Step 2: Check the following sections:
- Rule Information
Check if the settings for Customer Groups are correct. You will want to enable it for “NOT LOGGED IN” customers. Or you can try to enable it for all customer groups to see if the problem is solved.
In this section, check for existing conditions that may prevent the use of the code.
See if the Discard Subsequent Rules is set to active. It’s best to set it to No. While it doesn’t block the current coupon code, it will stop other ones.
Configure The Coupon Template
In case your coupon template doesn’t have the
formkey block, it also causes the bug of invalid coupon code.
Step 1: Find the template using
Step 2: Add the code inside the <form> element:
<?= $block->getBlockHtml('formkey'); ?>
Step 3: Reindex and clear cache with this command line:
php bin/magento indexer:reindex php bin/magento cache:flush
Step 4: Check if the coupon code can be applied now.
By following these methods, you can debug the “The promotional code you entered is not valid” error. As mentioned, promotional codes are handy to attract customers, so you need to ensure that customers can smoothly apply the code when they want to check out their cart.
Apart from the issue of promotional code, there are more frustrating ones in Magento, such as You Did Not Sign In Correctly/ Your Account Is Temporarily Disabled, Invalid Form Key. Please Refresh The Page, or 404 Error Page, etc. Follow Tigren’s blog to find how to resolve all of them!