Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Minimum order amount

Customers can’t check out until the cart reaches the amount you set. The cart says how much is missing.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1

Fill in your details first. Set your amount in $minimum and translate the message.

PHP
<?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

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.