The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Pop-up or similar message after customer enters coupon code.

purpleontimepurpleontime Member
in General edited October 2018
Hi there. Trying to see if this is possible without massive script creation.
Wanted to have a message pop-up when a customer enters a specific coupon code. I'm using the term "pop-up" but hoping there is a way to do that won't be blocked by a popup blocker.
Example scenario is:

1) Customer is checking out
3) After they enter the code, a message pops up saying, "Just a reminder, when using this coupon code the item you are purchasing will be FINAL SALE", followed by an "ok" button that closes the window upon clicking..

If anyone can help with this I'd really appreciate it!
thx in advance.

BTW, I would only want this to apply to a certain code, not across all coupon codes.
  • brettbrett FoxyCart Team
    Hi @purpleontime
    That'd be doable with just a small bit of code, but that code would be clientside, so you wouldn't want to have javascript like
    if coupon_code == 'THISSPECIALCOUPONCODE'
    Because anybody could just view source to find that code. My first thought would be to do it based off a hash of the coupon code, but give us a bit to discuss this internally.
  • that would be great. Thx so much Brett!
  • fc_adamfc_adam FoxyCart Team

    We've worked up a quick bit of code for you here, which will show an alert if the customer adds the specific coupon to the cart. You can paste this into the "footer" textarea of the "Add custom header and footer code to your templates" option found on the "configuration" page in the Foxy administration:
    {% if context == "cart" or context == "checkout" %}
    FC.client.on("cart-coupon-add.done", function(params) {
    for (var code in {
    if (code.toLowerCase() == params.coupon_code.toLowerCase()) {
    if([code].name == "My Coupon Name") {
    alert("Just a reminder, when using this coupon code the item you are purchasing will be FINAL SALE");
    {% endif %}
    You'll just need to update the script to change My Coupon Name to match the name of the coupon as it's entered into the Foxy administration. We check against the name there instead of the specific code to prevent the code being leaked publicly in the source code of your cart. It will then show a browser alert to the customer with the message as you pasted it above.

    I hope that achieves what you're after!
  • thank you! sorry for delayed reply
Sign In or Register to comment.