Set Minimum Order Amount
In this post you will learn how you can set a minimum order amount to your Woocommerce website with PHP. In our example, we will use a minimum order amount of five products.
You can set the amount by adding the following code to your functions.php file:
add_action( 'woocommerce_checkout_process', 'arrow_design_wc_minimum_order_amount' ); function arrow_design_wc_minimum_order_amount() { global $woocommerce; $minimum = 5; if ( $woocommerce->cart->get_cart_total() < $minimum ) { $woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s products to place your order.' , $minimum ) ); } }
Conclusion
We hope this Set Minimum Order Amount post was helpful and you are now able to set a minimum order amount also on your website! You can find more articles here:
Read another Woocommerce post : ‘Remove the Company Name from Woocommerce Checkout‘
Arrow Design, based in Dublin, Ireland, provides quality website design services in Dublin and beyond at affordable prices. If you would like help with implementing the above code, or any wordpress website development project, contact us. We love website design and it shows! We provide custom wordpress plugin development, website design training and lots more.
We do it all, so you don’t have to!
Related Posts
Woocommerce Account Page Hook Guide
In this article you will find a visual hook guide for the Woocommerce Account Pages, like the Login/Register page, the Downloads page or the Orders page.
Woocommerce Single Product Page Hook Guide
In this article you will find a visual hook guide for the Woocommerce Single Product Page. This should help you to quickly and easily find the hook positions on the page.
Woocommerce PHP – Product Categories by Product ID
In this tutorial you will learn how to check if a product is assigned to a tag, a category or a custom taxonomy. You can check if a product is is on the shop page, in the cart, in an order & more.
…We do more, so you can do less 🙂