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