How to Automatically Apply Coupon in WooCommerce in 2022

How to Automatically Apply a Coupon in WooCommerce in 2026

To automatically apply a coupon in WooCommerce, add a code snippet that triggers WC()->cart->apply_coupon() based on cart conditions, or use a plugin such as Smart Coupons or Advanced Coupons to enable auto-apply with a single toggle. This guide covers both approaches: a cart-total trigger, a shareable coupon URL, and the plugins that handle it without code.

How to Auto-Apply a WooCommerce Coupon Using Code

There are two code-based ways to auto-apply a coupon: trigger it when a customer’s cart hits a spending threshold, or trigger it when they click a coupon URL.

Method 1: Apply a Coupon When the Cart Reaches a Minimum Total

First, create the coupon itself. Go to Marketing > Coupons in your WordPress admin and click Add Coupon.

Set the coupon code, add a description, choose Percentage Discount as the discount type, and enter your discount amount (no % symbol needed). Then go to the Usage Restriction tab and set your minimum spend. For a 10% discount on orders over $100, publish the coupon with code 10OFF.

Without automation, the customer still has to copy that code and paste it at checkout, which is where discounts get missed. To apply it automatically, go to Appearance > Theme File Editor, open functions.php, and add:

/**
 * WebAppick – Apply Discount Coupon automatically to the cart
 */
function ts_apply_discount_to_cart() {
    
    $order_total = WC()->cart->get_subtotal();
  
    if( $order_total > 100 ) {
        $coupon_code = '10OFF';
        if ( !WC()->cart->apply_coupon( sanitize_text_field( $coupon_code ) ) ) {
            wc_print_notices();
        }
    }
}
add_action( 'woocommerce_before_cart_table', 'ts_apply_discount_to_cart' );

Add products to the cart to cross $100, and the 10OFF coupon applies automatically with the 10% deduction already reflected in the total.

Method 2: Apply a Coupon via a Coupon URL

Coupon URLs work well in emails, newsletters, or site banners. When a customer clicks the link, the coupon applies to whatever is already in their cart or to anything they add.

Add this to functions.php:

/**
 * WebAppick - Set session variable on page load if the query string has coupon_code variable.
 */
function ts_get_custom_coupon_code_to_session() {

    if( isset( $_GET[ 'coupon_code' ] ) ) {

        // Ensure that customer session is started
        if( !WC()->session->has_session() )
            WC()->session->set_customer_session_cookie(true);

        // Check and register coupon code in a custom session variable
        $coupon_code = WC()->session->get( 'coupon_code' );

        if( empty( $coupon_code ) && isset( $_GET[ 'coupon_code' ] ) ) {
            $coupon_code = esc_attr( $_GET[ 'coupon_code' ] );
            WC()->session->set( 'coupon_code', $coupon_code ); // Set the coupon code in session
        }
    }
}
add_action( 'init', 'ts_get_custom_coupon_code_to_session' );

/**
 * Apply Coupon code to the cart if the session has coupon_code variable.
 */
function ts_apply_discount_to_cart() {

    // Set coupon code
    $coupon_code = WC()->session->get( 'coupon_code' );

    if ( ! empty( $coupon_code ) && ! WC()->cart->has_discount( $coupon_code ) ){
        WC()->cart->add_discount( $coupon_code ); // apply the coupon discount
        WC()->session->__unset( 'coupon_code' ); // remove coupon code from session
    }
}
add_action( 'woocommerce_before_cart_table', 'ts_apply_discount_to_cart', 10, 0 );

Share URLs in this format:

https://yourWoostore.com/?coupon_code=10OFF
https://yourWoostore.com/cart/?coupon_code=10OFF
https://yourWoostore.com/checkout/?coupon_code=10OFF

The last two send customers straight to the cart or checkout with the discount already applied.

If you’re not comfortable editing theme files or troubleshooting PHP errors on a live store, a plugin gets you the same result without touching code.

How to Auto-Apply a WooCommerce Coupon Using a Plugin

Auto-Apply a Coupon with Smart Coupons (WebToffee)

Install and activate Smart Coupons for WooCommerce. Go to Marketing > Coupons and create or edit a coupon. The plugin adds a green-highlighted Auto Apply option to the standard coupon settings.

Enable that option, set your usage restrictions, and save. The coupon now applies automatically for any customer who meets the conditions, no code entry required.

Create an Auto-Apply Coupon URL with Advanced Coupons

Install and activate Advanced Coupons (the free version supports this). Go to Marketing > Coupons, create or edit a coupon, and open the URL Coupons tab.

Check Enable Coupon URL. The plugin generates a shareable link automatically; use the Code URL Override field if you want custom text at the end of the URL. In Redirect To URL, set where the customer lands after the coupon applies, and customize the success message if needed.

Send this URL by email, social media, or a site banner. Clicking it applies the coupon automatically.

Best WooCommerce Coupon Plugins for Auto-Apply Discounts

WebToffee Smart Coupons

Free plugin with a genuinely capable no-cost tier: BOGO deals, auto-apply coupons, URL coupons, scheduling, a bulk coupon generator, store credit, and gift cards. Over 30,000 active installs and a 4.7-star rating on WordPress.org.

Key features:

  • BOGO and Buy X Get Y deals.
  • Auto-apply coupons at checkout.
  • Store credits and gift cards.
  • Bulk coupon generation and CSV export.
  • Purchase history and shipping-based coupon conditions.

Pricing: free tier available. Paid plans start around $49/year for a single site. Check the official pricing page before publishing, since multi-site and lifetime tiers vary.

Smart Coupons (StoreApps)

An established all-in-one coupon plugin sold on the official WooCommerce Marketplace, with over 20,000 paying customers. No free version.

Key features:

  • Store credits, gift certificates, and gift cards.
  • BOGO deals and one-click auto-apply.
  • Bulk coupon generation and printing.
  • Customers can view their available coupons from My Account.

Pricing: starts from around $129/year for a single site at the time of writing. Check the official pricing page before publishing.

Advanced Coupons

A free plugin with a strong rules engine: cart-condition auto-apply, BOGO deals, and coupon URLs, with over 20,000 active installs and a 4.4-star rating.

Key features:

  • Free tier includes BOGO, cart conditions, and URL coupons.
  • Custom auto-apply coupon URLs.
  • Restrictions by user role, shipping method, and payment gateway.
  • Cart Conditions to prevent coupon misuse.

Pricing: free version available. Paid plans exist for stores that need more advanced conditions; check the official pricing page for current tiers, since figures vary across sources.

Auto Coupons for WooCommerce

A lightweight, free plugin that does one thing: applies coupons automatically when your set conditions are met, using WooCommerce’s native coupon conditions. No limit on the number of coupons.

Key features:

  • Simple, fast, single-purpose auto-apply.
  • Works with unlimited coupons.
  • Generates shareable auto-apply coupon URLs.
  • Built-in troubleshooting and cache-reset tools.

Pricing: free, available on WordPress.org.

Skip Coupon Codes Entirely with Discount Rules

If you’d rather not manage coupon codes at all, Disco applies percentage and fixed discounts automatically based on conditions you set, without a code for customers to enter or a plugin to auto-apply on their behalf. Customers see the discounted price on the product page and in the cart the moment they qualify.

Key features:

  • Cart-based, product-based, and role-based discount conditions.
  • BOGO and bulk pricing tiers.
  • Works with ACF, WPML, and major currency-switcher plugins.
  • No coupon code UI for customers to interact with at all.

Disco has a free core version on WordPress.org; check the official pricing page for current Pro tiers.

How to Show the Discount Amount on Your Invoices

Once a coupon auto-applies, your order confirmation and invoice should reflect it. WooCommerce core doesn’t generate PDF invoices, so this requires a dedicated plugin such as Challan.

Challan generates a PDF invoice automatically when an order is placed and attaches it to the confirmation email. To show the discount amount on that invoice, go to Challan > Settings > Invoice, scroll to the Discount section, and enable Show Discounted Amount. Every invoice generated afterward reflects the applied coupon.

Frequently Asked Questions

How do I automatically apply a coupon in WooCommerce?

WooCommerce core doesn’t include a built-in auto-apply option. Add a code snippet using WC()->cart->apply_coupon() triggered by a cart condition, or use a plugin like Smart Coupons or Advanced Coupons to enable auto-apply with a toggle.

Why isn’t my WooCommerce coupon auto-applying?

Check that the cart meets the coupon’s usage restrictions (minimum spend, product categories, user role), that the coupon hasn’t expired, and that no conflicting plugin is filtering woocommerce_before_cart_table. If you remove an auto-applied coupon manually, some plugins won’t reapply it until the cart changes again.

How do I apply a WooCommerce coupon using a URL parameter?

Add a coupon_code parameter to your store, cart, or checkout URL (for example, yourstore.com/cart/?coupon_code=10OFF). A code snippet or a plugin like Advanced Coupons captures that parameter and applies the coupon on page load.

How do I use Smart Coupons in WooCommerce?

Install and activate the plugin, then create or edit a coupon under Marketing > Coupons. Smart Coupons adds extra tabs and toggles, including auto-apply, directly onto the existing coupon settings screen.

How do I bulk edit coupons in WooCommerce?

Core WooCommerce doesn’t support bulk coupon generation or editing. WebToffee Smart Coupons includes a bulk coupon generator and CSV export in its free tier.

How do I apply a discount to all products in WooCommerce?

Select all products or categories manually in a coupon’s Usage Restriction settings, or use a discount rules plugin like Disco to apply a storewide discount without creating and maintaining a coupon.

Key Takeaways

  • WooCommerce core has no built-in auto-apply option; you need either a code snippet or a plugin.
  • A cart-total trigger snippet applies a coupon once a customer’s subtotal crosses a threshold you define.
  • A coupon URL snippet or plugin applies a coupon the moment a customer clicks a shared link.
  • WebToffee Smart Coupons and Advanced Coupons both offer free auto-apply functionality; StoreApps Smart Coupons is a paid, more feature-dense option.
  • Disco removes coupon codes from the equation entirely by applying discounts automatically based on conditions.
  • Challan can display the applied discount amount directly on generated invoices once auto-apply is set up.
Leave a Reply

8,544,556+ Downloads. 725+ plus 5-star ratings. Promote products on any platform you want.