1

Is there a way to limit users on my site to buy only 2 items from a list of products? Am using Drupal 7 with Commerce module and Rules. I added a new rule to when adding or removing and item from the shopping cart, it would check if the total quantity is bigger than 2, then it would remove the last element like this.

Event Before adding a product to the cart

After adding a product to the cart

Conditions

Total product quantity comparison Parameter: Order: [commerce_order], Operator: >, Quantity: 2

Actions

Remove an item from a list

Selected list: commerce-order:commerce-line-items

and the item to remove is

commerce-order:commerce-line-items:2

Sadly its not working, and I really need your help. thanks

closed as too broad by kiamlaluno Dec 17 '17 at 9:32

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • The conversation at drupalcommerce.org/node/673 may be useful to you, but you have more sophisticated requirements. – rfay Sep 21 '11 at 13:59
  • well, this is helpful but in my case cause I want the action to be removing an element from the cart. – saadlulu Sep 21 '11 at 14:46
  • stumbled on this, but if you are still looking for the rule(s) necessary to limit product quantities, you can see the post at <a href="drupalcommerce.org/node/1053">http://…> – Will Nov 28 '11 at 11:47
0

I had a similar problem: I had to check for certain conditions before adding an item to the cart (not after adding). And if the condition is not met the item should not be added.

The only way i could resolve this is by adding a "Execute custom PHP code" action with the code:

drupal_goto('any_path');

This doesn't look very correct but its the only thing that worked for me.

  • 1
    this doesn't seem to be very robust solution :) but it may came in handy – saadlulu Nov 28 '11 at 12:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.