Set minimum order amount in woocommerce

Set minimum order amount in woocommerce

Open Appearance> Theme editor> paste the code as below

add_action( ‘woocommerce_check_cart_items’, ‘required_min_cart_subtotal_amount’ );
function required_min_cart_subtotal_amount() {

// HERE Set minimum cart total amount
$minimum_amount = 250;

// Total (before taxes and shipping charges)
$cart_subtotal = WC()->cart->subtotal;

// Add an error notice is cart total is less than the minimum required
if( $cart_subtotal < $minimum_amount ) {
// Display an error message
wc_add_notice( ‘<strong>’ . sprintf( __(“A minimum total purchase amount of %s is required to checkout.”), wc_price($minimum_amount) ) . ‘<strong>’, ‘error’ );
}
}

 

Job Done

Leave a Reply

Your email address will not be published. Required fields are marked *

  ⁄  one  =  3