Get access to free tutorials, exclusive content and more.

Master Coupon Codes in WordPress Forms with These Simple Steps

Thought using coupon codes in WordPress forms was complicated? Think again!

Offering coupon codes as a flat or percentage discount is an excellent way for you to incentivize your product or service. You might have assumed there wasn’t an easy way to implement coupon codes in WordPress forms, but you were wrong.

You might have believed that only larger commerce plugins could handle this feature, but that’s not the case. Maybe you tried setting up coupon codes through your forms before and found it too complex.

Figuring it out from scratch can be challenging, but with this concise guide, it becomes a breeze. Now, you can effortlessly enable your forms to calculate discount coupon codes! Let’s explore how to do it.

How to Setup Coupon Codes in a WordPress Form

See the demo form below for an example of how to apply conditional logic to your existing form. You’ll need the Conditional Logic add-on installed and activated to apply the discount rate only when a coupon code is entered.

The demo form showcases a percentage discount, but you can use the same method for a flat discount as well.

Step 1: Add these 3 fields to your form

Here’s our demo form:

ninja forms coupon code form demo with 3 basic fields

 

  1. Coupon Code. This is a Single Line Text field. Customers enter the coupon code here.
  2. Discount Rate. This is a Hidden field that will contain the discount value.
  3. Total. This is an HTML field. However you’re currently handling your total price, you’ll need to use an HTML field to do this. You’ll see why in a minute.

The “Choose your plan” field represents the product/service to which you want to apply the discount. Ensure that the field supports calculations. Refer to this list for supported fields.

In the Discount Rate field, set the Default Value to 1 for a percentage discount and  0 for a flat discount. We’ll demo a percentage discount in this example, so the Default Value is set to 1.

discount rate field for ninja forms coupon codes with default value set to 1

 

Step 2: Create a single calculation to modify your total

To modify the Total with the discount rate of the coupon code, create a calculation using the Product and Discount Rate fields.

For a percentage discount, multiply the Product field by the Discount Rate field. For a flat discount, subtract the Discount Rate field from the Product field.

Navigate to the Advanced tab in the builder, open Calculations, and name your calculation. Set up the merge tags for the Product and Discount Rate fields. In this demo, we use a percentage coupon code and multiply the two fields.

calculation in ninja forms that makes it possible to use a coupon code, amount field times discount rate field pictured

Insert the merge tag for the calculation in your Total field to display the discount for the total.

the calculation's merge tag is pictured being entered into the HTML field labeled

 

Step 3: Set the total to be modified only if a coupon code is entered

In Step 1, we set the Default Value of the Discount Rate field for a reason. Here’s why. The calculation for the total is based on whether you offer a percentage or a flat discount.

Without a coupon code entered, the calculation multiplies by 1 or subtracts 0, leaving the total unmodified.

To modify the calculation when a discount code is entered, use Conditional Logic. Navigate to Advanced > Conditional Logic and create a new condition. For example, if the coupon code is “coffee” and it’s a 25% discount, set up the condition as follows:

Entering “coffee” into the Coupon Code field changes the Discount Rate field from 1 to 0.75 for a 25% discount. For a flat discount, enter the discount value. For example, for $25 off, enter 25.

✨ Note that Ninja Forms doesn’t generate coupon codes.

Bonus: Making a single-use coupon code field

To make your coupon codes one-time only, use the Unique Field setting. Create a Single Line Text field for customers to enter the coupon code and select it in the Unique Field settings under the Restrictions tab.

✨ Enable Developer Mode if you can’t see Restrictions under the Advanced tab.

Single Line Text Field

You can also display an error message if a user tries to submit the same coupon code more than once. Find this setting under Restrictions > Unique Field > Unique Field Error Message.

coupon code single use only

That’s it! Submitted codes can’t be reused. It’s that easy!

Create coupon codes for your WordPress forms with Conditional Logic today!

Whether you’re offering a percentage or flat discount with your coupon codes, it’s perfectly doable with your WordPress forms! All you need to do is pick up Conditional Logic or any Ninja Forms membership & follow the steps above.

In addition to changing values, our Conditional Logic lets you:

  • Show & Hide Fields.
  • Modify Lists.
  • Send Conditionally.
  • Set redirect destinations conditionally.
  • And much more.

Try Conditional Logic risk-free with a 14-day money-back guarantee! Get it for free with the Plus, Pro, or Elite membership, or choose from a one, five, or twenty-site license. Don’t wait; try it today!