It is currently not possible to modify promotion codes in the commercebuild Promotions Module. Furthermore, once a promotion code is inactive or deleted from the system, it cannot be used again, not even with a new promotion code.
If changes need to be made to a promotion code that has already been added to a user’s cart, your only option is to delete the promo code and/or create a new one.
In some cases, this may be inconvenient, especially if you have sent marketing emails with the code.
The Workaround
The JavaScript snippet below can be used to detect when a user has entered the “old” promotion code, notify the user that it has changed, and automatically update the promotion code with the new one.
<script> var old_promo = "OLDCODE"; var new_promo = "NEWCODE"; $('body').on('keyup', '#promo', function() { if ($(this).val().toLowerCase() == old_promo.toLowerCase()) { alert("We're sorry! This code has changed. Please use " + new_promo + " instead."); $(this).val(new_promo); } }); </script>
Installation Instructions
- Update the JavaScript snippet variables above to ensure
old_promo
andnew_promo
reflect your old promotion code and new promotion code, respectively. - Go to System > Modules > Custom Tags
- Click the New button
- Choose the Footer as the position of the code block
- Paste the modified JavaScript snippet into the text area
- Click Save
That’s it!
Be sure to test the functionality on both your Cart and/or your Checkout pages.