Why Auto-Apply Coupons?

Most customers forget to enter coupon codes at checkout, even if they’ve earned them through promotions.

By auto-applying a discount code, you:

  • Reduce cart abandonment
  • Increase conversions
  • Make the checkout process frictionless

For example: If a customer adds items worth $100, you can automatically apply a 10% discount coupon.

PHP Snippet: Auto-Apply a Coupon

/**
 * @snippet       Auto Apply Coupon in WooCommerce Cart
 * @author        Spiderwares
 * @compatible    WooCommerce 8+
 */

add_action( 'woocommerce_before_cart', 'spiderwares_auto_apply_coupon' );

function spiderwares_auto_apply_coupon() {
    $coupon_code = 'SAVE10'; // Replace with your coupon code

    if ( WC()->cart && ! WC()->cart->has_discount( $coupon_code ) ) {
        WC()->cart->apply_coupon( $coupon_code );
        wc_print_notices(); // Shows success message
    }
}

Result

As soon as the customer visits their cart, WooCommerce will auto-apply the coupon (if valid).

Example:
Cart Total = $100
Coupon Applied = 10% Off
Final Total = $90