Different amounts of product depending on the user role

A premium student asked me how he could limit the amount that a certain user role can buy a product:

He literally asked me:

I have a store and I have tried in every way and I cannot do the following, my store has 2 types of users (Customer, Distributor), what I want is that if your role is Customer you cannot buy more than 60 units of the product of the store (the store only has 1 product), but instead if you are a distributor you can buy the quantities you want.

There is a plugin that in principle was worth us, it is WooCommerce Advanced Product Quantities but care this plugin has a problem:

3 years without updating

When a plugin has not been updated for more than 3 years, there is a good chance that it will not work correctly.

These odds are even higher if you rely on WooCommerce as WooCommerce has changed its plugin a lot lately and extensions that haven't been updated don't work properly.

Indeed, I try it and it does not work well but there is still nothing lost 😉

Looking through the plugin comments I find the following message:

Different amounts of product depending on User Role 1

In this message a user tells us that he has made a modification to the plugin to make it work.

I have tried it and it works perfectly 👏 👏 👏

Subscribe to my channel:  

To use it, the first thing we have to do is download it from here:

https://github.com/jmclaren7/woocommerce-incremental-product-quantities

We install the plugin in our WordPress like any other plugin.

Once installed we find in the side menu of WooCommerce the item Quantity Rules

menu quantity rules

I click on all-rules and add a new rule

For the example I am going to create a rule so that the Administrator users can buy 100.000 products from the Music category and the Administrator Role

admin rule quantity rules

Now I'm going to create another rule for the Subscriber role, so that he can only buy 10 products from the Music category

subscriber rule quantity rules

I have also added the option for users to add products to the cart two by two, this is achieved with the field StepValue.

Now we do the test of trying to buy more of the products that we have defined in the rule and we see that it does not allow us:

Different amounts of product depending on User Role 2

In addition to making a rule for all the products in a category, we can do it for a specific product.

To do this we edit a product and we find the following fields:

plugin rules product fields

We have the possibility to deactivate the rules defined for all products or overwrite it and put a different rule for this product.

Leave a comment