Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello! I'd like to add a fixed global per-item limit of say 20 (that is, in addition to the existing inventory max limit). So max add-to-cart/in-cart for any item is lesser of 20 and available inventory.
Paid app functionality is overkill for my use case and I probably just need an at_most: or similar in the correct spot(s)? Any help is appreciated! Cheers
Hi @MisterC,
You are wanting the quantity limit to be 20, if the customer enters more than 20 it will automatically revert back to 20 for each product?
Please send me the theme name, I will check and guide you in detail.
@LitExtension Yes, that is exactly the desired function. (And of course if they entered more than 20 and the available inventory was 5, it would return 5). The theme is Drop by We Are Underground.
Hi @MisterC,
Does your product have many variants?
Because when there are many variants you need to add JS to change the max and min of quantity so it will be more complicated requirement and you need to hire expert for it.
Hope it is clear to you.
@LitExtension 99% of my products have no variants. For the occasional ones that do, if the desired functionality is problematic/complex, inventory will usually be limited anyways and the standard functionality would be fine.
For what I had in mind as possible approach though I wasn't thinking variants mattered. Particularly, the native behavior already handles inventory limitation by variant. No mods needed there. My thought was to add on to the existing logic (that is, item quantity limit = available inventory) an extra check (that is, item quantity limit = min (20, available inventory). Like with an at_most: function or similar. But my attempts failed, ergo here we are lol.
Cheers!
Hi @MisterC,
Please send me the code of product-template.liquid file, I will check and guide it for you
@LitExtension - I also need my cart to limit quantity purchased. I need a minimum limit of 2 and a maximum of 20. I'm only selling one product in my cart. My theme is Debut.
Hi @LB2022,
You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.
Hi @MisterC,
Go to product-buttons.liquid file and add code here:
Code:
<label for="{{ section.id }}-productQty-{{ product.id }}">
{% assign max = 20 %}
{% if product.selected_or_first_available_variant.inventory_policy == 'deny' and product.selected_or_first_available_variant.inventory_quantity < 20 %}
{% assign max = product.selected_or_first_available_variant.inventory_quantity %}
{% endif %}
<input id="{{ section.id }}-productQty-{{ product.id }}"
min="1"
max="{{ max }}"
data-limit="{% if current_variant.inventory_management == 'shopify' %}{% unless current_variant.inventory_policy == 'continue' %}{{ current_variant.inventory_quantity }}{% endunless %}{% endif %}"
type="text" name="quantity"
class="product__quantity-input vib-center"
value="1" />
<span class="visually-hidden">{{ 'products.product.quantity' | t }}</span>
</label>
Hope it helps!
I would like to know if the script can be used to restrict only 1 item in the cart and the quantity also in 1 item? That's what I need. Only one item can be added to the cart and the quantity is also limited to 1.
Sure, that works, but you can still add the item to the cart again if you're on a Featured Product page, the page isn't refreshing, so you can still add 1 after 1 after 1 etc to the cart...
Hey @MisterC,
This extension Limit Quantity Purchasehelps you to set the maximum and minimum quantities for your store.
The features of this app are as below:
1. Specific Product purchase limits Minimum and Maximum.
2. Flexible Purchase Limit of items within a group of products.
3. Apply Limit For individual products or collection
It has all the features that you have mentioned in your query. Please, check it out here for more details: Shopify Limit Qty Purchase
Hope this helps you.
Thank you.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024