Wordpress

How to automatically apply coupon in Woocommerce

How to add a coupon programmatically 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 about it.

How to add a coupon 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 in know the easy route to do the same?
Keep Scrolling.

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 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 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 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?

  • Select Discount Rules for WooCommerce plugin in WooCommerce on your WP dashboard.
  • Click Settings in the plugin dashboard.

Step 1

Automatic Coupons are associated only with cart discounts. The automatic coupons you create will get applied on the cart page of your WooCommerce store.

  • Navigate to Cart Rules under Settings tab.
  • Enter the name of the coupon code that needs to apply automatically to cart.
  • Choose Apply first matched rule in the rule setup for cart.
  • Apply first matched rule means the coupon code discount will automatically apply when the customer satisfies the first discount condition in your WooCommerce store.

Step 2

The General data of the coupon discount like Rule name, Rule description, Validity are entered in this page.

Major fields to look into in this section are,

Order: The order number will prioritize the discounts for your WooCommerce customer in case the customer satisfies two discount rules at the same time.

WooCommerce Smart Coupon Example: Exclusive 20% Coupon Discount on Cart Total!

  • The customer gets a 20% coupon discount automatically applied on the checkout page when purchasing for a minimum $100.

Well, the above discount is an advanced WooCommerce discount and the reason is

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

Step 3

  • Choose Subtotal at least under Cart subtotal in the Type drop-down list.
  • Subtotal at least is the discount condition that checks the minimum cart total.
  • Add the minimum cart total for the coupon to apply automatically.

Step 4

  • Since the coupon discount is a simple percentage discount, choose percentage discount in the discount type list.
  • Enter the percentage discount value which is 20 in this coupon scenario

Finally,

This is How the Cart looks when the coupon discount is programmatically added to the checkout page,
The customer gets a 20 % Coupon discount added ( Coupon code- Snow discounts!) 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 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?

Step 1

  • Start by navigating to Cart Rules under Settings tab.
  • Choose Apply biggest discount in the rule setup for cart.
  • Apply biggest discount means the coupon code discount will automatically apply to the biggest discount rule in your WooCommerce store.
  • Next, to enable Free Shipping, Choose Woo-discount Free shipping in the drop box.
  • Well, you can make the shipping discount look attractive by adding Shipping discount texts too.

Step 2

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.

Scroll down to step 4 if you already know how to add discounts programmatically,

The General data of the shipping discount like Rule name, Rule description, Validity are entered in this page.

Major fields to look into in this section are,

Order: The order number will prioritize the discounts for your WooCommerce customer in case the customer satisfies two discount rules at the same time.

WooCommerce Free Shipping Coupon : FREE Shipping Coupon! On all purchases above $100.

The Customer gets Free Shipping when the minimum shopping total is $100

Step 3

  • Choose Subtotal at least under Cart subtotal in the Type drop-down list.
  • Subtotal at least is the discount condition that checks the minimum cart total value.
  • Add the minimum cart total for the coupon to apply automatically.

Step 4

This is the tab where the Shipping discount gets differed from the other percentage discounts.

  • The discount tab decides the type of discount and its value.
  • Since the coupon discount is a simple percentage discount, choose Free Shipping in the discount type list.

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

The customer gets a Free Shipping discount added ( Free Shipping Text- Santa on the Way!) automatically to the cart page as the cart total is above $100.

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

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.