Skip to main content

Sometimes, you may want to set a minimum order amount for customers to proceed to checkout in your WooCommerce store. This is especially useful for stores offering bulk discounts or to ensure profitability on low-margin items. With a few lines of code, you can enforce this restriction and display a custom message when the minimum order amount isn’t met.

Follow these steps to add a minimum order amount requirement to your WooCommerce checkout.

Step 1: Add the Code to Your Theme’s Functions File

To implement the minimum order amount functionality, you’ll need to add a custom code snippet to your theme’s functions.php file or a custom plugin. Here’s the code:

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

function set_minimum_order_amount() {
$minimum_order_amount = 50; // Set your minimum order amount here

// Check the cart total
if ( WC()->cart->get_cart_total() < $minimum_order_amount ) {
if ( is_cart() ) {
wc_print_notice(
sprintf(
'You must have an order with a minimum of %s to proceed to checkout.',
wc_price( $minimum_order_amount )
),
'error'
);
} else {
wc_add_notice(
sprintf(
'You must have an order with a minimum of %s to proceed to checkout.',
wc_price( $minimum_order_amount )
),
'error'
);
}
}
}

Customize the Minimum Order Amount

In the code above, change the value of $minimum_order_amount to your desired minimum order amount. For example, if you want the minimum order to be $100, update the line:

$minimum_order_amount = 100;

Step 3: Customize the Error Message

You can modify the message displayed to customers when their cart total is below the minimum amount. Look for these lines in the code:

'You must have an order with a minimum of %s to proceed to checkout.'

Replace the text with your preferred message, but keep the %s placeholder, as it dynamically inserts the minimum amount.

Example:

'Your cart total must be at least %s to complete your purchase. Please add more items to your cart.'

Step 4: Save and Test

  1. Save the changes to your functions.php file.
  2. Visit your WooCommerce store and add items to the cart.
  3. Attempt to proceed to checkout with a cart total below the minimum amount to test the error message.