Skip to main content
Login Join
Snippet · PHP

Add a Custom Discount Message on the WooCommerce Cart Page

Shared by Amit Dholiya · September 2, 2026 · @woocommerce_before_cart

9 views
Back to Snippets

You can automatically show a message on the Cart page when a customer reaches a specific order value. This is useful for promoting discounts, free gifts, or special offers.

Steps

  1. Open your theme’s functions.php file.
  2. Add the code below.
  3. Save the file.
  4. Add products to your cart and test the message.

Done — customers will see a special offer when their cart reaches the specified amount.

function show_cart_discount_message() {

    if ( ! WC()->cart ) {
        return;
    }

    $minimum_amount = 100;
    $cart_total     = WC()->cart->get_subtotal();

    if ( $cart_total >= $minimum_amount ) {
        echo '<div class="woocommerce-message">
            🎉 Congratulations! You qualify for a special discount.
        </div>';
    }
}

add_action(
    'woocommerce_before_cart',
    'show_cart_discount_message'
);
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments