How to set a minimum order amount in WooCommerce

Useful article if you administer online stores built with wocommerce and you want to know how to set a minimum order in WooCommerce. In the default settings of an online store self-hosted, checkout option does not exist. Therefore, establishing the minimum amount for an order, will be done by another method.

Compared to a physical store, one online often imposes new rules, depending on the clients to whom the products marketed, their value and the payment and delivery methods.

If there is no problem in a physical store if we enter and buy a product of 10 cents, in an online store things are a little different. Any order made by a client involves some costs from the store. From the simple processing of the order to the packing, shipping, all these operations need time.
When the sale offer contains very cheap products, it is good to put a minimum amount for each order. For example, an order cannot be completed if the total products in the basket do not reach the amount of 10 euros.

How to set a minimum order amount in WooCommerce

The simplest method is to add a personalized function in functions.php through which you can set the minimum amount for order in WooCommerce.

Open the file functions.php of the active theme (preferably be Child-theme) and add the following code:

// Set Minimum Order Amount in WooCommerce
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
 
function wc_minimum_order_amount() {
    
    $minimum = 10; // Set this variable to specify a minimum order value

    if ( WC()->cart->total < $minimum ) {

        if( is_cart() ) {
            wc_print_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( $minimum )
                ), 'error' 
            );
        } else {
            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( $minimum )
                ), 'error' 
            );

        }
    }
}

Also from here is set the message by which the buyer is warned that he does not have products whose total amount does not reach the minimum limit for placing the order.

How to set a minimum order amount in WooCommerce
Your current order total is 3,00 € — you must have an order with a minimum of 10,00 € to place your order

For WooCommerce some online payments modules offer automatic support for setting the limit amount from which an order can be made.

This function is useful for online stores that sell products with low prices, which cannot cover processing and shipping costs.

Passionate about technology, I write with pleasure on stealthsetts.com starting with 2006. I have a rich experience in operating systems: Macos, Windows and Linux, but also in programming languages ​​and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, Presashop).

Home Your source of IT tutorials, useful tips and news. How to set a minimum order amount in WooCommerce
Leave a Comment