Vote up!
Vote down!

Maximum order for all attributes of a product

Hi there,

I've read many answers here and can't seem to figure this out. I have a product that is available in 6 different languages. I don't want customers to order more than 4 total products, in any language. At the moment, I've set a rule to stop the customer from ordering 4 copies of a product in one language, but this doesn't translate to the total in all languages.

So for the moment, the customer can't order more than 4 English products. But they can order 4 English, 4 French, 4 Spanish.

I would like them to have a maximum total of 4 for the product in English, French or Spanish.

Is this possible?

Asked by: eleonoreft
on March 4, 2014

1 Answer

Vote up!
Vote down!

eleonoreft -

Without setting up a custom drupal commerce site just to test this, I'd say you want your rule to only check for SKUs -- unless you have a SKU per language. If that is the case, you would need something that ties each of the SKUs together so that your rule will know how to group, count, and limit the products. For that, I would add a secondary field to products and then create a custom Rule condition (blog post with untested stub code).

Josh Miller
Answer by: Josh Miller
Posted: Mar 5, 2014


thanks! I'm actually realizing that I can't even limit the number of items added to a cart on the add to cart form. Do you know how this can be done?

- eleonoreft on March 5, 2014

Sure! Did a little reading in the issue queue and found this gem: https://drupal.org/node/1658788 ... Turns out there really isn't a way in rules to stop a product from being added to the cart. Lots of options in the issue above, some have tried creating a rules condition "so many product A's are currently in cart" and a rules action "remove this item from the cart" ... which is counter intuitive to what commerce_stock does. Commerce_stock sets the price to NULL on products that should not be added to the cart. You could take that queue and build a pricing rule that sets the price to NULL if there are two many products in the cart --- but you would have to be careful that it only affected the product not in the cart, not all the products regardless of position in cart.

Good luck!

- Josh Miller on March 5, 2014