Adding Minimum Order Amounts in WooCommerce

Sometimes you may want to prevent customers from checking out if their cart value is less than a given dollar value.

Prevent small purchases through your WooCommerce store by setting a minimum purchase amount.

For ease of use you may copy/paste these snippets into your functions.php file, or copy and paste this code into your own plugin. It’s also quite easy to adjust this code to set a maximum purchase amount, or a combination of max and min amounts in order to check out.

add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );

function wc_minimum_order_amount() {
	// Set this variable to specify a minimum order value
	$minimum = 2500;

	if ( WC()->cart->total < $minimum ) {

		if( is_cart() ) {

			wc_print_notice(
				sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order ' ,
					wc_price( WC()->cart->total ),
					wc_price( $minimum )
				), 'error'
			);

		} else {

			wc_add_notice(
				sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order' ,
					wc_price( WC()->cart->total ),
					wc_price( $minimum )
				), 'error'
			);

		}
	}
}
Written by Shawn Wernig

Shawn Wernig

Lead Creative at Eggplant Studios

Shawn Wernig is the lead creative behind Eggplant Studios. While not full time (let's face it, more than full time) designing websites for his clients, Shawn enjoys good beer, double-doubles, and hiding from his phone.