Introducing WPLoyalty – Points, Rewards & Referral plugin for WooCommerce with tons of reward options.  
Get 10% as intro offer: Coupon Code: SAVE10

how to automatically apply coupon in woocommerce

How to Automatically Apply Coupon in WooCommerce

How you doin’.

So, What’d be the reason for you here?

Me guessing….

Well, you must have been half-way exploring Woocommerce in finding a way to add coupons programmatically. Right?

If so, this post from Discount Rules for WooCommerce gets your back covered.

Though WooCommerce is the most popular eCommerce platform, it has its own constraints in creating advanced coupons.

Okay. By now, you would surely know how to create a coupon code in WooCommerce. Let’s not dwell on it.

How to apply coupon code programmatically in WooCommerce- That’s the one you’ve been looking for, right?

Just add the following to your functions.php file after creating your WooCommerce coupon,

Interested to know the easy route to do the same?

Keep Scrolling.

how to automatically apply coupon in woocommerce

Before getting started, make sure you have installed and activated the popular WooCommerce Discount plugin – Woo Discount Rules:

Discount Rules PRO- The Smart Coupon Management Plugin

Why do the hard way, if a coupon management plugin can do the above task for you automatically. Discount Rules for WooCommerce PRO is an advanced coupon management plugin that allows you not only to create coupons but also adds WooCommerce auto apply coupons programmatically to the cart.

programmatically with this plugin installed, you’ve got no worry about discount constraints, and coupon limitations because, Discount Rules for WooCommerce PRO = Coupon Management Plugin + Dynamic Pricing Plugin + Price Variation Discount Plugin

The plugin has got the simple procedure to add coupons automatically to the check-out page. Also, this post gives more than what you just came for. It also shares a WooCommerce auto discount idea to reduce cart abandonment.

How to add a coupon programmatically in Woocommerce

Before you start, please download and install the Discount Rules for the WooCommerce PRO plugin. The guide assumes that you already have the plugin installed and activated.

So, after getting your WooCommerce store equipped with the smart coupon plugin, Where should you navigate to create automatic Coupons?

Navigate to WooCommerce -> Woo Discount Rules -> Add New Rule.

add new rule

Once you have entered the rule page, enter the rule name and select the discount type as “Cart Adjustment” from the drop-down as illustrated below,

validity and limitation

In the filter section,
Choose “All Products”.

In the discount section,
Choose the discount type as “Percentage Discount” with the discount value as 20%.
Enter the coupon label as “Clearance Sale”.

In the rules section,
Condition type – Subtotal with its value as greater than or equal to $100.
The discount rule is also set with limitations and validity

Cart Discount + Automatic Coupon Code + Time- Limited Offer = Advanced Cart discount rule/ Advanced Coupon code.

Have a look at the cart page for better understanding,

20% coupon applied

This is how the cart looks when the WooCommerce of applied discount is programmatically added to the checkout page,

The customer gets a 20 % Coupon discount added ( Coupon code- clearance sale) automatically to the cart when the total goes above $100.

Note- The coupon discount is applied automatically and this gets confirmed as the Apply Coupon text box remains empty.

How to apply Free Shipping discount automatically in the check-out page

Free Shipping is an exclusive cart discount. Cart discounts apply to the cart page of your WooCommerce store and the biggest advantage of cart discounts is that it controls cart abandonment.

And what happens when cart abandonment gets reduced? Won’t it boost your sales conversion?

The steps to create this Shipping discount follows the same procedure as of the above cart total discount. Well, the steps are shared again to make it easy for those who directly scrolled here.

Enter the rule name and select the discount type as “Free Shipping” from the drop-down in the rule page as illustrated below,

free shipping configuration

In the rules section,
Condition type – Subtotal with its value as greater than or equal to $100.
The discount rule is also set with limitations and validity.
It means when the customer’s order is above $100, he/she is offered with free shipping.

Well, see how cart abandonment can be reduced with this coupon management plugin. This is How cart page looks when the Shipping coupon is applied automatically,

free shipping cart

Definitely not the hardest of procedures! Right?

Discount Rules for WooCommerce is the best coupon management plugin in the niche. And when it comes to adding of coupon automatically to the cart, no plugin hits the bullseye.