Dynamic discount messages can strongly influence buying decisions by showing customers that they are close to unlocking a better deal.
Instead of forcing users to search for coupons, you guide them in real time.
In this tutorial, you will learn how to display an automatic discount suggestion message in WooCommerce using hooks.
Why This Works So Well
Customers are highly motivated when they feel they are “almost there” in reaching a discount threshold.
- Encourages higher cart values
- Increases conversion rates
- Reduces coupon confusion
- Improves shopping experience
The WooCommerce Hook We Will Use
We will use:
woocommerce_before_cart
This hook allows us to display messages at the top of the cart page before checkout actions.
Example Code
Add this code to your theme’s functions.php file or a custom plugin:
add_action('woocommerce_before_cart', 'auto_discount_suggestion_message');
function auto_discount_suggestion_message() {
$threshold = 100;
$discount_message = "You're close to unlocking 10% OFF!";
$cart_total = WC()->cart ? WC()->cart->subtotal : 0;
if ($cart_total >= $threshold) {
echo '';
echo ' Discount unlocked! You already qualify for 10% OFF.';
echo '';
return;
}
$remaining = $threshold - $cart_total;
echo '';
echo '' . $discount_message . '
';
echo 'Add $' . $remaining . ' more to unlock your discount.';
echo '';
}
How It Works
- Checks current cart total
- If threshold not reached → shows encouragement message
- If reached → shows success message
Customization Ideas
- Multiple discount tiers (5%, 10%, 15%)
- Show best products to reach discount faster
- Add countdown timer for urgency
- Personalize messages for logged-in users
