How to prevent buyers from adding multiple units of a product in the shopping cart.

Solved
Highlighted
Tourist
12 0 1

Hello,

 

I sell digital downloads extended licenses, and there is no need for a buyer to buy more than one copy of a product. 

This isn't something that happens very often, but from time to time users start adding products to the cart and mistakenly add a second copy of a product.

 

How can I stop a user to add multiple copies of a product? Is there any app or should I custom code that feature?

 

Thanks

0 Likes
Highlighted
Shopify Partner
1085 221 287

Hello,
You have to custom code the feature.
1) Remove quantity box from product and cart.

2) Check in product pages that is this product already in cart. 
Once you do it you can hide or disable button accordingly and if your theme is using ajax to add item in cart then you have go in that function and code it accordingly.

Thanks

Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
Skype: navrocks1
If helpful then please Like and Accept Solution.
If you are happy and want to donate small Click here (Its my paypal)
0 Likes
Highlighted
Tourist
12 0 1

Awesome, thanks!

 

Besides removing the quantity counter in the shopping cart, the logic would be to add code to the product page, so when it loads, it checks the shopping cart and disables the buy button. 

 

Can that be done with Liquid, or should I use JS to check the shopping cart?

 

Enrique

 

 

0 Likes
Shopify Partner
1085 221 287

This is an accepted solution.

Yes Enrique, its possible.
It can be done in both ways using liquid or JS.
For liquid you can take idea from cart page code and for JS  you can use this

    $.getJSON("/cart.js", function(res) {
      console.log(res.items);
      for(var i = 0; i < res.items.length; i++) {
        //alert(res.items[i].id);
        if(res.items[i].id == $product_id) {
          // Your code
        }
      }
     }); 



Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
Skype: navrocks1
If helpful then please Like and Accept Solution.
If you are happy and want to donate small Click here (Its my paypal)
1 Like
Highlighted
Tourist
12 0 1

Excellent, that was really helpful

 

Thanks!

 

Enrique

0 Likes