Hi,

I'm using Ubercart (new user) to sell memberships. I want to limit the quantity of «product» to 1. Moreover, when a user adds a new product, I would like any previous product in the cart to be removed, so even if the user makes a mistake, he/she ends up with only one role.

There the restrict_qty module does not seem to work (WSOD). Can this be achieved with Rules? If so, how?

Thanks for your help.

NG

Comments

TR’s picture

Status: Active » Fixed
Issue tags: -cart rules

No, Rules are not a good way, because quantity can be set/changed in several places. The best way to do this is with code like uc_restrict_qty. If that module doesn't work for you, please help out in the issue queue for that module.

longwave’s picture

However, this is certainly possible with Rules, but may not work with all contrib modules (those that do not handle cart items using the Entity API)

{ "rules_restrict_quantity" : {
    "LABEL" : "Restrict quantity",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "uc_cart" ],
    "ON" : [ "uc_cart_item_presave" ],
    "DO" : [ { "data_set" : { "data" : [ "uc-cart-item:qty" ], "value" : "1" } } ]
  }
}

You can restrict the quantity for one specific product by adding a condition to compare the node ID property.

Northern_Girl’s picture

Thanks!

But I have missed something because items keeps piling up in the cart.

And what will happen if a user adds a different role say one week before the end of a membership? Is this managed by uc_roles or should Rules be used?

Sorry for these "ubercart newbe questions"

NG

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.