Conditionally Altering the minimum wholesale order amount

Like WooCommerce itself, I put a lot of hooks into my own plugins to allow other plugins to modify things (including my own plugins that work with each other).

My Wholesale Ordering plugin has a minimum order amount that you can set that will be applied to Wholesale Customers. If you set that field to any value, then a wholesale customer must always meet or exceed that order amount before they are allowed to checkout.

But, what happens if you want to have a different minimum amount after the first order, or after the customer has spent a certain amount, or even just a minimum amount for the first order?

Thankfully, I have a simple filter hook on that amount before it is checked in the cart or checkout pages. The line of code with the filter looks like this:

$minimum = apply_filters( 'woocom_wholesale_minimum_order_amount', (float)$this->wholesale_minimumOrder);

If you want to change that conditionally based on the amount the customer has spent, we can tap into that filter hook, and then use one of the WooCommerce functions to get the total amount the current user has spent so far. So, if you want to change the minimum required amount after their first order, you just need to check to make sure the amount the user has spent is more than zero, and then change the value that is returned to whatever you want. That can be either a different minimum, or you can return a zero value if you don’t want any minimum after the first order. Note that you must have an amount set for the minimum order amount in the Wholesale Ordering plugin settings for this to hook to be triggered.

So, let’s say you set the minimum amount in the settings to be $500, but then after they make their initial order, you want to lower that to $100. You could do that with the following code snippet in your child theme’s functions.php file:

function ssp_alter_order_minimums_wholesale($minimum) {
   if(is_user_logged_in() ) {
      $id = get_current_user_id();
      if(wc_get_customer_total_spent($id) > 0) {
         $minimum = 100.00;
   return $minimum;
add_filter('woocom_wholesale_minimum_order_amount', 'ssp_alter_order_minimums_wholesale');

You can modify the value on the line that says: $minimum = 100.00;
and change the number to whatever value you want. Make sure you don’t delete the semicolon at the end!!

Also, if you want their total spending to be above a certain amount before they get a different minimum (or maybe no minimum, by setting minimum to zero), just change the value of 0 in the if statement above the $minimum line. For example, if you want them to spend at least 1000 before they no longer get a minimum, change the comparison to >= 1000, and the minimum to zero, such as:

if(wc_get_customer_total_spent($id) >= 1000) {
         $minimum = 0;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.