← Back to All Snippets

Add Custom Minimum Order Amount Requirement in WooCommerce

⚡ Target: functions.php 🔒 Tested: WooCommerce 8.0+ / WP 6.6+ 💻 Lang: PHP
PHP (functions.php)
add_action( 'woocommerce_checkout_process', 'tipwp_require_minimum_order_amount' );
add_action( 'woocommerce_before_cart', 'tipwp_require_minimum_order_amount' );
function tipwp_require_minimum_order_amount() {
    $minimum = 50; // Set minimum order threshold in store currency
    $cart_total = WC()->cart->total;

    if ( $cart_total < $minimum ) {
        $notice = sprintf( 'A minimum order total of %s is required to place your order. Your current total is %s.', wc_price( $minimum ), wc_price( $cart_total ) );
        if ( is_cart() ) {
            wc_print_notice( $notice, 'error' );
        } else {
            wc_add_notice( $notice, 'error' );
        }
    }
}

Enforce a storewide minimum checkout threshold in WooCommerce. If a customer attempts to checkout with a cart value below the threshold, an error notice is triggered preventing checkout.

← Back to All Snippets Explore Dev Tools →