Skip to content
Snippet

Set a minimum order amount in WooCommerce

Block checkout until the cart subtotal reaches a minimum, with a clear notice.

PHP · functions.php
add_action( 'woocommerce_check_cart_items', function () {
	$minimum = 50; // Store currency.
	if ( WC()->cart && WC()->cart->get_subtotal() < $minimum ) {
		wc_add_notice(
			sprintf( 'Your order must be at least %s before checkout.', wc_price( $minimum ) ),
			'error'
		);
	}
} );
Where to put itPaste it into your child theme’s functions.php, or add it with a code-snippets plugin. Never edit the parent theme — updates overwrite it.

Last updated September 24, 2026 · Code is GPL-2.0-or-later.

Get a quote