commercebuild Success Portal commercebuild Success Portal

  • Home
  • Submit a Ticket
  • Updates
  • Login
  • Contact Us
Home / Tutorials / Updating Promotion Codes

Updating Promotion Codes

571 views Less than a minute 0

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

  1. Update the JavaScript snippet variables above to ensure old_promo and new_promo reflect your old promotion code and new promotion code, respectively.
  2. Go to System > Modules > Custom Tags
  3. Click the New button
  4. Choose the Footer as the position of the code block
  5. Paste the modified JavaScript snippet into the text area
  6. Click Save

That’s it!

Be sure to test the functionality on both your Cart and/or your Checkout pages.

webstore Tutorials

About Bradly Hale

View all posts by Bradly Hale →

Related Articles

  • How to Enable reCAPTCHA on Custom Forms
  • Adding a custom message to the shipping step at checkout
  • How to configure Stripe as a payment method
  • SQL Server Change Tracking Query for Sage 300 and X3

Popular Articles

  • Enable Firewall Rules and a JavaScript Browser Challenge 2247 16
  • Enable Cloudflare Rate Limiting 2134 0
  • How to Add a JavaScript Snippet 1994 8
  • IP Allowlist 1945 0
  • Signing up for Cloudflare and Configuring Your Domain 1812 4

New Articles

  • Error when adding a new user: Email is already in use 676 0
  • How to Check commercebuild Payments Version 913 0
  • How to Enable reCAPTCHA on Custom Forms 820 0
  • Manually posting an order 970 0
  • Adding a custom message to the shipping step at checkout 785 0
© commercebuild 2022. All rights reserved.