For many e-commerce businesses, setting a minimum order amount is a strategic move to increase average order values and ensure that each transaction covers the operational costs. In WooCommerce, setting up a minimum order amount can help you maintain profitability and reduce handling smaller orders that might not be cost-effective. In this guide, we’ll walk through how to set a minimum order amount in WooCommerce, using a simple function added to your theme’s functions.php
file or a custom plugin.
Why Set a Minimum Order Amount?
Setting a minimum order amount can be crucial for managing shipping and handling costs effectively. It ensures that all orders meet a certain value threshold, which can help cover the costs and increase the average order size. This practice is especially useful for stores selling bulk items, offering wholesale rates, or even small businesses needing to maximize each sale for profitability.
Implementing Minimum Order Amount in WooCommerce
Implementing a minimum order amount in WooCommerce involves adding custom code to your site. This code checks the cart’s total and compares it to your specified minimum before allowing checkout.
Step 1: Add Custom Code
Open your WordPress dashboard, navigate to Appearance > Theme Editor, and select your theme’s functions.php
file. Insert the following code at the end of the file:
/*
* Snippet: How to Set Minimum Order Amount in WooCommerce – 2024
* Author: John Cook
* URL: https://wcsuccessacademy.com/?1090
* Tested with WooCommerce 8.8.3
*/
function wcsuccess_set_minimum_order_amount() {
// Set the minimum order amount
$minimum = 50;
// Total we are going to be checking against
$cart_total = WC()->cart->total;
// Compare cart total to minimum order amount
if ( $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( $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( $cart_total ),
wc_price( $minimum )
), 'error'
);
}
}
}
add_action( 'woocommerce_checkout_process', 'wcsuccess_set_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wcsuccess_set_minimum_order_amount' );
Step 2: Customize the Minimum Amount
In the code above, $minimum = 50;
sets the minimum order amount to $50. You can change this value to whatever minimum you want to set for your store.
How Does It Work?
The code hooks into WooCommerce actions related to the cart and checkout process. It checks the cart’s total against the set minimum and displays an error message if the total is less. The check occurs both when viewing the cart and attempting to checkout, ensuring customers are aware they need to meet the minimum order amount before proceeding.
Best Practices
When you set a minimum order amount, consider how it aligns with your business goals and customer expectations. Here are a few tips:
- Communicate Clearly: Make sure your customers know about the minimum order amount by displaying this information prominently on product pages, the cart page, and during checkout.
- Adjust as Needed: Monitor customer responses and adjust the minimum order amount if necessary to find a balance that works for your audience and your business needs.
- Consider Exceptions: You might want to exclude certain products from the minimum order requirements or adjust the minimum during promotions.
Conclusion
To set a minimum order amount in WooCommerce, you just need a snippet of code and a clear understanding of your business needs. By choosing to set a minimum order amount, you ensure that every transaction contributes positively to your business’s profitability and efficiency. Remember, the key is to keep your customers informed and to strike a balance that maximizes both customer satisfaction and your business objectives.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Google Scholar ID: https://scholar.google.com.au/citations?user=0KvpwNEAAAAJ&hl=en
ORCID: https://orcid.org/0000-0001-8113-1296
Stay In Touch