Shopify themes, liquid, logos, and UX
Hi,
I've looked thru the forum and can't seem to find what I'm trying to achieve (aside from the ubiquitous "use an app".
I'm looking for a simple solution to limit the amount of a single product that can be added to a shopping cart.
As an example, I have 50 units of a product in stock available to sell, but only want a max of 20 to be able to added to the cart.
One would think that it should be a core part of Shopify, give a request was make nearly 2 years ago on another thread.
I'm not looking for a lot of bells and whistles that come with some apps.
Ideally it would also create a message/popup that says for "bulk orders please contact us directly".
I'm using the Debut theme.
Come on Shopify, you say you support small businesses. If you talk the talk how about its time to walk the walk and get it done!
Thanks
ok So I've eventually found this thread :
and it has solved the problem at a basic level.
BTW the product-template liquid file is in "sections".
I'm not good at code and got it done, so its a pity Shopify wouldn't add this feature, as it should be simple.
thanks @Huanineupane
For a simple feature like this Shopify should code it in the backend instead of store owners having to do the heavy lifting, please pull up your socks Shopify and make this a basic offering.
Unfortunately the above fix is only a "half " fix.
It works on laptop/desktop where arrows are used to add to the quantity.
It does not work on mobile (where 90% of my customers are)
On mobile it is still possible to type in a higher quantity and successfully add to cart.
The further coding for this is beyond me, so if anyone has suggestions, they will be appreciated.
Thanks !
Change the type of the field from number to text. Did that work for you?
This will only stop someone from selecting a higher value when adding to cart all at once. This doesnt stop them from going back to the item and adding another unit.
My store is looking for this functionality as well. I am not super knowledgeable when it comes to coding, but I've tried a couple solutions I've come across on these forums and none of them quite work.
It's just mind-blowing to me that this still isn't a native feature in 2022. We already use about a dozen apps for relatively simple feature add-ons, and installing more just isn't sustainable or acceptable.
We have a popular USA-exclusive product that we want to limit to 1 per customer to prevent resellers from buying them up and shipping them out of the country via freight forwarders (which is ANOTHER problem for which Shopify's solution is "get an app"). We've tried adding language in the product description that says "Limit one per customer" but this message just gets ignored. And it's a pain for our customer service team to cancel these orders after the fact.
Hoping Shopify finally gets around to adding this feature soon (or someone comes along with a good coding solution).
Hi! I'm trying to do the same exact thing. any chance you have found a solution to this? I'd be happy sharing knowledge so we can both make this work
Hello @chrisr408
I understand you are not looking for app, but I don't think such solution is available by default in shopify at the moment.
I would suggest to check out our app for it
https://apps.shopify.com/purchase-limit?
This feature would be great!
We also would love this feature. We are planning on having a free + shipping test product that customers can try out to see if they like our product. Obviously we don't want to sell 30 units for free to a customer. It would be great if Shopify had an intrinsic feature to limit the quantity for certain products.
Yes it feels odd that after years of requests for this basic shop feature it is still not available in the core Shopify. While Multi-Language and other features might be complicated in core I do not think this one should be consuming much time from the core coder team.
I really wonder how shopify will evolve regarding this and other features pretty standard in the main competitors but only available by subscriptions Apps in shopify.
You can do this with Custom Data by adding a field to all your products called Max Cart Quantity, then edit your Liquid templates in the right place to set the max="" field on the Quantity <input HTML tag.
Steps:
It should look like this once saved:
Note the custom field key of product.metafields.custom.max_cart_quantity.
Now lets edit your theme:
<input
class="quantity__input"
type="number"
name="quantity"
/>
Edit it to add a max field with a condition like:
{%- if product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity != null %}
max="{{ product.selected_or_first_available_variant.product.metafields.custom.max_cart_quantity }}"
{%- endif %}
Note the custom field key of product.metafields.custom.max_cart_quantity that was configured in our Custom Data for Products.
Now you can go edit any of your products and edit the Max Cart Quantity custom field that you made.
Presently, in that code there is already a max variable! in main-product.liquid:
{% if product.selected_or_first_available_variant.quantity_rule.max != null %}
data-max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
max="{{ product.selected_or_first_available_variant.quantity_rule.max }}"
{% endif %}
So the code is there now!! But there is no place to set that max variable in the store or product. 🤔
I've worked on this for a bit.. and there are a few things that can be done to keep it simple:
1. Make sure the field on the "View Cart" page has a min, max, pattern, make it read only and hide the buttons if the line item of the cart contains a word (for example). Make sure that the sidebar cart has the exact same stuff in it.
2. Make sure that the product page or the button that you have implemented on any page is only there if the item isn't already in the cart. There's code floating around for this in this community.
And for now.. if you want to keep it simple..:
3. For those same product page or button.. make sure that it redirects to the cart (add hidden input field called return_to and give value of /cart. (or add this to the href string)
I'm trying to get some javascript together that would go around this last one.. because I have a page where the customer needs to stay on the page after the 'add to cart' click, but needs to check if the item is in the cart. It does find it in the cart, but can't figure out yet how to prevent to have it actually add to the cart...
Only issue that I have at this point is the cart drawer. Not sure how to check there for the name or price of the line item...
I am building my first online store and beginning to think I should have gone with another ecommerce platform as the basic functionality (quantity limits, purchaser email verification options, etc) are still not available after neraly 5 years. And to see the issue was 'solved' by subscribing to an app is absolute poor form Shopify. Reconsidering my initial choice...
I am seriously regretting moving across from Square Space.
This should easily by a Shopify native function. We want to offer our customers a one time sample of our product, surely we should need ANOTHER app for this. It's bad enough we need an App to send our customers a Tax Invoice!
Also looking for a solution to this and commenting for support. Please fix this missing feature Shopify
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024