Useful article if you manage online stores built with WooCommerce and you want to know how to set a minimum order amount in WooCommerce. In the default settings of an online store self-hosted, the Checkout option does not exist. Therefore, establishing the minimum amount for an order will be done by another method.
Compared to a physical store, an online one often imposes new rules, depending on the customers it addresses, the type of products sold, their value and payment and delivery methods.
If in a physical store there is no problem if we go in and buy a product for 10 cents, in an online store things are a little different. Any order made by a customer also involves some costs from the store. From the simple processing of the order to packaging and shipping, all these operations take time.
When the sale offer contains very cheap products, it is good to put a minimum amount for each order. For example, not being able to complete an order if the total number of products in the basket does not reach the sum of 10 Euros.
How to set a minimum order amount in WooCommerce
The simplest method is to add a custom function in functions.php through which you can set the minimum amount for the order from WooCommerce.
Open the file functions.php of the active theme (preferably 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'
);
}
}
}
This is also where the message is set, by which the buyer is warned that he has no products whose total amount does not reach the minimum limit for placing the order.
- How to automatically delete product images in WooCommerce, together with the product
- Fixed wc-ajax = get_refreshed_fragments High CPU Usage (Disable AJAX Cart Fragments)
- How to quickly delete all orders (Orders) from WooCommerce [SQL Tips]
- How to uncheck default “Ship to different address” from the Woocommerce Checkout page
For WooCommerce some modules for online payments offer automatic support for setting the limit amount from which an order can be placed.
This function is useful for online stores that sell products with low prices, which cannot cover the processing and shipping costs.