2

Is there any way to allow user only one product in cart. I used uc_restrict_qty but After that i can add more than one products also.

  • There is no need for a carts if you can't have products in them. If you want your users to buy one at a time, why not to just remove cart altogether and add "buy now" button? I can't imagine anyone else wanting basically useless cart. On the other hand, if you want only one product of a given type, uc_restrict_qty should do that - report bug there if it doesn't. – Mołot May 18 '13 at 9:11
  • 1
    Also check this drupal.org/project/uc_product_minmax – Bala May 18 '13 at 9:28
  • uc_restrict_qty - If you already had a copy of that product in your shopping cart, you should empty your cart and add it again. Due to the way the module works, it won't restrict quantities on products already in customers' shopping carts. – Bala May 18 '13 at 9:31
3

If the module uc_restrict_qty not working file your issue there. Alternatively You can achieve this with help of hook hook_uc_add_to_cart

hook_uc_add_to_cart($nid, $qty, $data) 

Performs extra processing when an item is added to the shopping cart.

Inside hook you can check your conditions, and prevent your new item to add.

uc_cart_get_contents() can used to get existing contents of cart. If it is greater than 1 you can do your logic here, either remove previous one and add the current one or remove the new item

  • thanku.... I used hook_uc_add_to_cart and empty the cart if qty is 1.. – Sumit Madan May 18 '13 at 9:42
  • @NikhilM oh yes.. :D – Sumit Madan May 20 '13 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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