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.

Adding Minimum Order Amounts in WooCommerce
Shawn Wernig
June 19, 2024
by Shawn Wernig

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'
			);

		}
	}
}
Eggplant Studios - Custom Website Design and Development
Creating custom web solutions and happy clients since 2002
COPYRIGHT ©
2024
Eggplant Studios
- ALL RIGHTS RESERVED
LOGIN