In this article we will explore how to set a minimum order quantity or minimum order amount in your WooCommerce store. You can do this with our premium plugin, B2BKing, by creating dynamic rules.
The plugin enables minimum order rules per product or per category, for all users, individual users, or specific groups. You can thus have different minimum order values for different customers (a common setup for b2b or wholesale stores).
Let's first of all look at how to set a minimum order quantity. You can try everything out for yourself in our plugin demo to see exactly how it works.
Go to B2BKing->Dynamic Rules and create a New Rule.
In our example above, we have created a rule, that applies to the "Wines" category, for users in the "Resellers" group, of minimum 500 items.
If users try to purchase anything less, they will see the following error in cart, and will not be able to checkout:
In the checkout page, depending on your theme, users are prompted to resolve the issues in cart:
It's very simple to set up, and it can be set up for products or categories, for users or groups in all sorts of combinations. You can even create a minimum quantity rule for a specific product variation (for WooCommerce variable products).
Cabernet Sauvignon 2018 can be purchased in minimum 5 bottles by all users. Here's what the configuration looks like:
The rule will apply to only this specific product, which can now be purchased in minimums of 5. If they try to purchase any less, users will see the following error:
This functionality is different from required package/box quantity. Scroll down below to find out how to set items to be purchasable in multiples of X.
To set minimum order value, you can use the same system and simply choose "Value" instead of "Quantity" in the dynamic rule dropdown.
Let's see an example: setting a minimum order for all B2B users of $2000.
This is the configuration:
And the result in the cart page:
Notice that the previous notification about minimum orders of 5 is still present as well. Multiple minimum rules can be stacked and checkout will only be allowed when all the purchase conditions are met by the customer.
Another common requirement in wholesale e-commerce is selling certain items in multiples of X (6 in a box, carton of 12, etc). You can do this with B2BKing's "Required Multiple" rule. This rule will only allow customers to purchase certain products in multiples of the chosen number.
Let's see an example: the following item is purchasable only in multiples of 6, since that's the box size:
If the user tries to purchase for example 8, they will see the following error in cart:
This rule also supports Conditions. For example you can set that this rule applies only for orders over 100 items. So if the customer wants to purchase below 100, they can do so in any multiple, but if they are placing a larger order, in that case their purchase must follow box size rules. Below is how this can be configured:
Another functionality in the plugin is Minimum Order to use a particular payment method or gateway. For example, you can enable Bank Transfers only for orders above $5000.
This is very simple to set up, simply create a new Dynamic rule with a configuration like this:
Customers will not see this method at all in checkout, until their purchase is over the $5000 threshold.
Besides minimum order rules, the plugin also supports maximum order rules. For example, if you have customers that are new and you do not have a well-established relationship with them, you can place them in a group that has a maximum order quantity or value.
In the example above, users in the "Factories" group, can purchase items in the "Computers" category for a maximum of $10000. If they attempt to purchase more, they will not be able to checkout.
Finally, if you are a developer or if you are familiar with coding, we would like to share some code snippets and ways to set this up in WooCommerce.
add_action( 'woocommerce_checkout_process', array('B2bking_Dynamic_Rules', 'b2bking_dynamic_minmax_order_amount') );
add_action( 'woocommerce_before_cart' , array('B2bking_Dynamic_Rules', 'b2bking_dynamic_minmax_order_amount'));
As you can see above, the 2 WooCommerce hooks you need to use are woocommerce_checkout_process and woocommerce_before_cart, so that conditions are checked in both cart and checkout.
Inside the function itself, the code looks like this:
function b2bking_dynamic_minmax_order_amount(){
// first of all, calculate the value or quantity in cart
$cart = WC()->cart;
$cart_total = 0;
$cart_quantity = 0;
$limit = 2500; // example limit
foreach($cart->get_cart() as $cart_item){
$cart_quantity += $item_qty; // ctotal number of items in cart
$cart_total += $item_line_total; // calculated total items amount
}
if ( $cart_total > intval($limit) ) {
if( is_cart() ) {
wc_print_notice(
sprintf( esc_html__('Your current order quantity total of %s is %s — the maximum quantity you can order is %s ','b2bking') ,
$product_name,
$product_number,
$howmuch
), 'error'
);
} else {
wc_add_notice(
sprintf( esc_html__('Your current order quantity total of %s is %s — the maximum quantity you can order is %s ','b2bking') ,
$product_name,
$product_number,
$howmuch
), 'error'
);
}
}
}