Hey there, we noticed you didn't complete your Advanced Coupons purchase.

We're excited to have you join the Advanced Coupons family! Complete your checkout now & save!
If you have any questions, please reach out to our support team!

How To Get WooCommerce To Add Discounts Programmatically

How To Get WooCommerce To Add Discounts Programmatically

Coupons should be easy to use. For a lot of users, copying or transcribing long coupon codes can be a hassle. If you want as many people as possible to take advantage of the deals you set up, you’ll want to consider configuring WooCommerce to add discounts programmatically.

If you’re using Advanced Coupons, that process is easier than you might think. The plugin offers more than one way to automate or semi-automate coupon applications. That way, you can ensure no customer is left out.

In this tutorial, we’ll talk about why it makes sense to set up WooCommerce to add discounts programmatically. Then we’ll show you two ways to do it. Let’s get to work!

Why You Should Simplify The Coupon Application Process

Discounts and promotions are perhaps the most powerful tools at your disposal to increase sales, and coupons enable you to implement both. The only downside to using coupons is that you leave a lot of work in your customer’s hands.

If you send a coupon code via email and a user doesn’t see it, they can lose out on potential savings. Even if you add a big notice on your homepage, a lot of visitors might overlook it.

In our experience, customers that find out they could’ve gotten a discount on their purchases but didn’t aren’t a particularly happy lot. They might be more likely to complain and less likely to buy again.

Coupon Discount Example
Coupon Discount Example (click to zoom)

Ideally, you’d like to avoid both scenarios. A smart way to do so is to configure WooCommerce to add discounts programmatically. In other words, if a purchase fulfills a set of specific conditions, it gets a discount without users needing to do any extra work.

With that approach, you can minimize the number of users that miss out on promotions. If everything goes smoothly, you’ll get more sales and your customers should be happier – it’s a win-win.

How To Get WooCommerce To Add Discounts Programmatically

In WooCommerce, the easiest way to automate and run site-wide discounts is by using a plugin such as Advanced Coupons:

Advanced Coupons is the highest-rated coupon plugin in WooCommerce
Advanced Coupons is the highest-rated coupon plugin in WooCommerce

With Advanced Coupons, you can set up anything from discounted shipping to Buy One Get One (BOGO) deals, all through the magic of coupons. Plus, you can get WooCommerce to add discounts programmatically in more than one way.

1. Use the auto-apply feature when you add discounts

Advanced Coupon’s auto-apply feature does exactly what its name promises.

You can enable it independently for each coupon you offer. If a customer’s purchase meets the criteria for a coupon with auto-apply enabled, they won’t need to enter the code manually.

Turning on that feature is simple. All you have to do is open the coupon editor and look for the Auto Apply Coupon section on the right side of the screen:

Getting WooCommerce to add discounts programmatically.
Enable auto apply setting (click to zoom)

Before you enable auto-apply for any coupon, it’s important you properly configure its restrictions and/or conditions. For example, you might want to limit that coupon’s usage to once per customer, which you can do under Coupon data > Usage limits:

Configuring usage limits for your coupon.
Configure coupon’s usage limits (click to zoom)

To set cart conditions, you can scroll down to the Cart Conditions > Rules section.

Here, you can use a simple conditions system to ensure customers meet specific criteria before the plugin auto-applies that coupon:

Some examples or cart conditions for a coupon.
Set and configure cart condition (click to zoom)

You can enable auto-apply for as many or a few of your coupons as you want. We recommend you use the feature only for those discounts you don’t want any customers to miss, though.

2. Enable a one-click coupon application

Advanced Coupons also lets you set up a one-click-apply option for your customers. This approach isn’t precisely automatic, but it’s as close as you can get without enabling auto-apply for your WooCommerce discounts.

One-click coupon application is perfect if you don’t feel comfortable turning on auto-apply for your discounts. It makes coupons easy to apply without taking all the work off your customer’s hands, which can be a good thing.

Enabling one-click coupon application.
Enable one click apply notifications (click to zoom)

Another benefit of this approach is you can customize your one-click-apply notifications. That includes everything from the apply button text to error messages and more:

You can find that option as well as its accompanying settings under Coupon data > One Click Apply Notification. Keep in mind that this is also a coupon-specific option. That means if you want to offer a one-click coupon application for all your discounts, you’ll have to enable the setting for each of them.


Automating coupon applications makes it easier for users to take advantage of the deals you set up for them. With programmatically-applied coupons, you can ensure no user loses out on a deal because they didn’t check their email or see the notices you set up.

With Advanced Coupons, you can get WooCommerce to add discounts programmatically in two ways:

  1. Use the auto-apply feature.
  2. Enable a one-click coupon application.

Do you have any questions about how to get WooCommerce to add discounts programmatically? Let’s talk about them in the comments section below!

author avatar
Editorial Staff

Leave a Reply

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