Enabling Coupon Codes Using Gravity Forms

I have been trying to create a form using Gravity Forms that correctly accepts coupon codes, but couldn’t figure it out until now! I asked the Gravity Forms support team for help on this and received this response:

“If you do want the form to validate the coupon code, you will need to use that [gform validation] hook you mentioned. However, we are actively working on a coupon add-on that should help you out here. Keep an eye out on the blog for when it’s released.”

I don’t have enough know-how to implement the hook, so I decided to work on my conditional logic a bit more, and I figured out a solution for coupon codes that works!

I used a product field with a negative value that is hidden unless user enters a valid coupon code. Using the “conditional logic” option, this negative-value product field only shows when an active coupon code is entered (each active coupon code is set as an accepted value).

No discount is given until the user selects discounted price option PLUS enters a valid code in the “required” coupon code box.

Works great!

Join the Conversation


  1. Brady —
    Thanks so much for saving me a ton of time. I needed to be able to create a coupon field in GF for a non-profit fun run registration form.

    Your explanation worked perfectly!

    1. Hi Christine,

      So glad that you found the explanation and happy to hear that it worked for you! Thanks for letting me know – its great to hear that something I share ends up helping someone else too. Best of luck with the fun run.

  2. Great post. I am having trouble understanding how you created your ‘product field with a negative value that is hidden’. Is this done within the same Product Field a the original cost?


    1. Its a separate product field. You create the new pricing field, call it something like “Coupon Code Discount”, add a negative value as the price, and within the “Advanced” area you enable conditional logic and “Show” the field if the coupon code field is a specified value (the specified value being whatever you want the coupon code to be…say 4557).

      1. Thanks, I managed to figure it out. I created a ‘single line text’ field for the Coupon Code and a ‘product’ field for the Discount.

  3. There’s two downsides to this technique – there’s no validation for the code, which is where the hook comes in – but I could live without that.

    The other issue might just be for 1.7.6 (the version I’m currently using) – the total field doesn’t work correctly. This technique does work – it sends the correct amount to the payment processor. But prior to that, the hidden field is always calculated into the total, so the total always appears as though someone has activated the coupon code when they actually haven’t. I tried all sorts of workarounds – everything I could think of – but no joy in getting the total to register correctly.

    If you ask me, this is a Gravity Forms bug – the total should always reflect the total that gets sent to payment processors at any moment – but I’m guessing this is a super-niche instance so I’m hesitating to file a bug report.

    1. I’ve tested with versions 1.7.5 and 1.7.7 and it works on both. The total field updates correctly, and the hidden negative amount only shows and applies when the correct code is entered.

      As for the validation for the code – what do you mean? On the backend, I simply enter each numeric code I want to use and the discount is only applies when the correct code is entered.

  4. Hi Brady,

    Its nice to see this post. Its very helpful, but I was wounding if we can use same technique to put discount in %age (Percentage). I mean its easy to put -negative value of product to reduce amount, but what if we want to reduce amount in percentage.


    1. Hi Atiq,
      I’m not sure about percentage discounts. Can you give it a shot and let us know if it works?
      I did see that Gravity Forms released a coupon add-on, and its available with a developer’s license, so that may be something that you can use if you have a developer’s license.

  5. Great, but the only problem with this is that the promotion code is visible in “view source” any one with enough programming knowledge can find it.

    1. This may be the case, I haven’t tested it. For this client, that wouldn’t be a big enough issue so we can use this method without worrying about the small chance that someone will find the code in the source code, but I can see how in other cases, that could be a problem. Thanks for the heads-up!

  6. Man,
    Thanks Brady

    you saved me 150$ by not paying for the coupon add on proposed in the developer version.

    Thanks for sharing your trick with everybody, very useful

    All the best


Leave a comment

Your email address will not be published. Required fields are marked *