How to Automatically Apply a Coupon on Payment Forms

How to Automatically Apply a Coupon on Your Payment Forms

Editorial Note: We may earn a commission when you visit links on our website.

Do you want to auto-apply coupon codes on your payment forms after a special link is clicked?

Everyone knows that people love discounts. But what they love even more is the convenience of directly heading to a checkout form without having to manually enter a coupon code.

You can easily add this convenience for your customers in WordPress with the right plugins.

In this post, we’ll guide you on creating a payment form that automatically applies coupon codes for your loyal customers.

Create Your Coupon Code Form Now

What’s the Benefit of Automatically Applying Coupons?

Applying coupon codes automatically improves customer experience by eliminating the need to manually find, copy, and paste a coupon code inside a form.

Customers are less likely to abandon your payment form if they see the discount already applied as soon as they click the link to your form.

The result is an increased conversion rate as more and more customers complete payments after seeing an attractive discount in place for them.

This is why using forms with already inserted coupon codes is such a powerful sales technique that you should also consider using.

How to Automatically Apply a Coupon on Your Payment Forms

It’s really easy to set up forms that automatically apply coupon codes for customers. Just follow the steps below.

Step 1. Install WPForms

The easiest way to generate coupons and simplify the process of adding them to your form is to use the WPForms plugin.

WPForms is one of the best-rated WordPress plugins, having  4.9/5 stars on WordPress.org.

You’ll need the WPForms Pro license to access the Coupons addon, which comes with all the functionalities you need to set up coupon codes with prefill option enabled.

WPForms Pricing Page 2023

When you’ve purchased your license, go ahead and install WPForms on your website. It will only take you a few minutes.

In the next step, we’ll set up the Coupons addon.

Step 2. Install the Coupons Addon

After installing WPForms, open your WordPress dashboard and navigate to WPForms » Addons.

Once inside the addons screen, look for the Coupons addon and press the Install Addon button under it.

Install WPForms Coupons addon

It will just a few seconds to install the addon. You’ll see the Status change to Active once the addon is ready to use.

Coupons addon ready

With these steps out of the way, we can now go ahead and create a coupon code.

Step 3: Create a New Coupon

While you’re inside the WordPress admin menu, click on WPForms » Payments.

WPForms payments summary

The Payments screen has a Coupons tab that allows you to create any number of coupons for your site. Click on the Coupons tab to proceed.

Coupons tab

Next, click on the Add Coupon button.

Add coupon option - WPForms

You’ll now be taken to a new screen where you can set up your new coupon. Here, you can enter the name, code, amount, and configure other settings for your coupon. You’re free to enter a custom code or have WPForms auto-generate one for you if you want.

You can also set your coupon’s start and expiry date and place a maximum usage limit. Leave these fields empty if you don’t want to limit coupon validity by time or number of uses.

Coupon settings

Scroll to the bottom to select which forms from your existing forms the coupon can be used on. Because we haven’t created a form for this coupon code yet, we can come back to this step later.

Click on Save Coupon to save your newly created coupon code.

Save coupon settings

Now that you’ve created your coupon, it’s time to build a payment where the coupon can be used on.

Step 4: Create a Payment Form

Creating forms is the easiest part of using WPForms, thanks to its rich library of over 1,700+ form templates.

To start building your form and access the template library, simply go to WPForms » Add New.

Add new form

Enter a name for your form. The name is used only internally for your reference so you can identify your forms easily.

Enter form name

Then scroll down and select a suitable template. For this tutorial, we’ll use the Stripe Payment Form template because it closely meets the requirements for our goal.

Use payment forms template

Note: Make sure you’ve set up the Stripe integration with your account before launching this payment form. You’ll need it to collect payments online.

Once you’ve clicked on a template, it will load in the form builder. You can make any edits you want to the fields, layouts, and other settings of the form.

For instance, this template has all the fields you need to accept payments, but it doesn’t have a coupon field for discounts.

So, we’ll drag and drop the Coupon field just above the Total field.

Coupon field

Now, we’ll select which coupons this field can accept. Click on the Coupons field to open Field Options. Then click on the Allowed Coupons dropdown and select the coupon you’d like your customers to be able to want to be valid for this form.

Select a coupon

Make sure to press the Save button at the top when you’re finished customizing the payment form.

Step 5: Enable Prefill by URL

In order to configure your form to auto-apply coupon codes, you’ll need to enable prefill by URL.

This option is located in Settings » General inside the form builder.

General form settings in WPForms

Scroll down the General settings and click on Advanced to expand additional options. After you’ve done that, click on the Enable Prefill by URL toggle button.

Enable prefill by URL

Also, make sure that you’ve enabled payment for whichever payment gateway you’re using for your form.

For example, if you’re using Stripe, go to Payments » Stripe and click the Enable Stripe Payments toggle button. Without this, you won’t be able to collect payments from customers filling out your form.

Enabling Stripe payments for a form

Similarly, if you’re using PayPal, Square, or Authorize.net, make sure you’ve set up the appropriate integrations and enabled payments from your form builder.

Excellent! We’re now ready to publish this form.

Step 7: Publish the Payment Form

Click on the Embed button at the top to start the publishing process for your form.

Embed your form with the embed button

You’ll be prompted to select one of two options between embedding the form in an existing page or a new page. We’ll choose to embed in a new page by clicking on the Create New Page button.

Create new page

Name your form and press Let’s Go.

Enter a name for your new page

At this point, you’ll see your WordPress block editor open with your form already embedded.

When you’re ready to launch, press the Publish button at the top.

Publish the tshirt order form

Excellent. With this form, the coupon code will already be prefilled after your users click a special URL.

But you’ll have to construct this special URL for that to happen. We’ll cover this in the next step.

Step 8: Construct URL for Auto-Filling Coupon Code

The auto-filling functionality for the coupon code field will only work after you’ve modified your new form page URL appropriately.

You’ll need 3 things to construct a URL capable of auto-applying the coupon code:

  • Form ID
  • Field ID
  • Coupon code

You can find the Form ID for your form by going to WPForms » All Forms and locating the form you want to apply the code on. Take a look at the shortcode column next to your form and notice the number. This is the Form ID, which in our case, is 67.

Form ID

Now, click on the form to open it. We need to find the Field ID of the Coupon field. This can be easily done by clicking on the Coupon field and looking at the ID# next to the field name under Field Options.

Coupon field ID

Finally, you need the exact coupon code that you created for the coupon applicable to this form.

If you don’t remember the code, you can find it by going back to WPForms » Payments and clicking on the Coupon tab. The code will be written in a column to the name of your coupon.

Coupon code

Now that we have all the pieces together, we can compose our special URL for auto-applying the coupon code.

Let’s assume that the URL for your form page is https://sulliesflowers.com/buy-shoes/.

We now need to modify it in the following way:

https://sulliesflowers.com/buy-shoes/?wpf[Form ID]_[Field ID]=[Coupon Code]

In our case, the values we need to insert are:

  • Form ID: 67
  • Field ID: 6
  • Coupon Code: 30OFF

Inserting these values into the formula for the modified URL, we get:

https://sulliesflowers.com/buy-shoes/?wpf67_6=30OFF

That’s it! Now if your customers click on your link, they’ll find the coupon code already applied as soon as your form loads.

Auto-apply coupon code

You can send this special URL for the coupon code to your customers via your newsletter or other marketing channels to get people to click and enjoy your discounts.

And there you have it!

You now know how to automatically apply a coupon on your payment forms.

Next, Set Up Recurring Donations

If you’re a nonprofit preparing to run a donation campaign, you can benefit greatly by setting up recurring donations instead of offering only one-time donations. You can see our guide on how you can boost recurring donations for tips.

If you’re looking for more details about coupon plugins available for WordPress, you may want to read our roundup of the best coupon code plugins for WordPress.

We also have a guide that shines more light on why WPForms is rated so highly on Trustpilot.

Create Your Coupon Code Form Now

Ready to build your form? Get started today with the easiest WordPress form builder plugin. WPForms Pro includes lots of free templates and offers a 14-day money-back guarantee.

If this article helped you out, please follow us on Facebook and Twitter for more free WordPress tutorials and guides.

Using WordPress and want to get WPForms for free?

Enter the URL to your WordPress website to install.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.