shopify - Limit product to only one per customer
I'm trying to code a solution for a client, that doesn't wish to use apps. We need to be able to limit one of our products, so there only can be one of it in cart at a time.
Is there an easy way to achieve this without an app?
Thank you, Magnus
Any time you have a call to add to cart, ensure the quantity is 1 Any time you have a call to add to cart, first ensure that item is not in the cart
When you render the cart, take all the inputs for updating the cart away. Allow only delete.
With that, you can hope that for the most part, customers will only ever have one of something in the cart.
You can then focus on removing any ability to change the quantity when adding to cart, and ensuring that when checkout is selected, items do in fact only have a quantity of 1.
No Apps needed.
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.