Setting a minimum order amount is a common strategy for increasing profitability and covering shipping costs.
However, customers should always be clearly informed when they haven’t reached the minimum requirement.
In this tutorial, you will learn how to show a dynamic warning message in WooCommerce when the cart total is below a required minimum.
Why Minimum Order Warnings Improve UX
Instead of silently blocking checkout, you guide customers toward the required amount in a friendly way.
- Reduces checkout frustration
- Increases average order value
- Improves clarity and transparency
- Encourages additional purchases
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.
Example Code
Add this code to your theme’s functions.php file or a custom plugin:
add_action('woocommerce_before_cart', 'minimum_order_warning_message');
function minimum_order_warning_message() {
$minimum_amount = 50;
$cart_total = WC()->cart ? WC()->cart->subtotal : 0;
if ($cart_total >= $minimum_amount) {
return;
}
$remaining = $minimum_amount - $cart_total;
echo '';
echo ' Minimum order not reached.
';
echo 'Add $' . $remaining . ' more to proceed to checkout.';
echo '';
}
How It Works
- Checks current cart total
- Compares it with minimum required amount
- Shows warning message if condition is not met
Customization Ideas
- Add progress bar toward minimum amount
- Show suggested products to reach threshold
- Apply different minimums per country
- Combine with free shipping goal system
