Minimum Order Amount

This snippet sets a minimum order amount for checkout, preventing users from placing orders below a certain value.

PHP

function set_minimum_order_amount( $min_amount = 50 ) {
    if ( WC()->cart->total < $min_amount ) {
        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( $min_amount )
            ), 'error' 
        );
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
    }
}
add_action( 'woocommerce_check_cart_items', 'set_minimum_order_amount' );

Snippet Feedback

Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY

Tags

Language

Did it work?

Save Snippet

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.