Item quantity limit = min (constant, available inventory)

MisterC
Tourist
3 0 0

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

Replies 11 (11)

LitExtension
Shopify Partner
4860 1001 1133

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 - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
MisterC
Tourist
3 0 0

 

@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.

 

 

LitExtension
Shopify Partner
4860 1001 1133

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 - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
MisterC
Tourist
3 0 0

@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!

LitExtension
Shopify Partner
4860 1001 1133

Hi @MisterC,

Please send me the code of product-template.liquid file, I will check and guide it for you

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
LB2022
Excursionist
22 1 4

@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.

LitExtension
Shopify Partner
4860 1001 1133

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.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

LitExtension
Shopify Partner
4860 1001 1133

Hi @MisterC,

Go to product-buttons.liquid file and add code here:

Screenshot.png

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!

 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
DMIDIAS
Visitor
2 0 0

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.

DutchDelight
Excursionist
19 0 4

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...

 

janvi_22
New Member
20 0 0

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. 

 

banned