How to set minimum order amount in woocommerce ? | themelocation

How to set minimum order amount in Woocommerce ?

In this tutorial we’ll learn how to set minimum order amount in woocommerce. By default in woocommerce you can order upto any amount but sometimes you need to limit the customer’s purchases to a limit. We can achieve this quite easily.

Place the following lines of code at the end of your functions.php file.

add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
 
function wc_minimum_order_amount() {
 
                global $woocommerce;
 
                $minimum = 50;
 
                if ( $woocommerce->cart->get_cart_total() < $minimum ) {
 
           $woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order.' , $minimum ) );
 
                }
 
}

Replace the value of variable 50 with the amount you want to set as your minimum limit.

You can access functions.php here:

woocommerceSave the file after placing code.

Now when the user try to checkout having cart amount less than minimum limit they’ll receive this error.

woocommerce

2 Responses to How to set minimum order amount in Woocommerce ?

  1. Ashok February 29, 2016 at 4:09 am #

    Hello friends,

    We have created a plugin for solving this issue you can find it here
    https://wordpress.org/plugins/woo-min-max-quantity-limit/

    • Hatibunda.com April 27, 2016 at 4:01 pm #

      I was use your plugin, but i can’t set unlimited max quantity.

Leave a Reply