Minimum order amount
Customers can’t check out until the cart reaches the amount you set. The cart says how much is missing.
Fill in your details first. Set your amount in $minimum and translate the message.
<?php
// The smallest order you accept, in your shop's currency (products only,
// before shipping and coupons, as shown in the cart).
$minimum = 20;
add_action(
'woocommerce_check_cart_items',
static function () use ( $minimum ) {
$cart = function_exists( 'WC' ) ? WC()->cart : null;
if ( ! $cart || $cart->is_empty() ) {
return;
}
$total = (float) $cart->get_displayed_subtotal();
if ( $total < $minimum ) {
wc_add_notice(
sprintf( 'The minimum order is %1$s. Your cart comes to %2$s.', wc_price( $minimum ), wc_price( $total ) ),
'error'
);
}
}
);
Good to know
Tested with the classic cart and checkout.
In these packs
- WooCommerce essentials: The small WooCommerce changes shop owners ask for most.