Setting Maximum Inventory Quantity

Setting Maximum Inventory Quantity

glassmaker
Tourist
4 0 2

Is there a way to limit the product quantity a customer can add to their cart to be no more than what you've set as available in the inventory?

 

Looked at previous main-product.liquid suggestions which are a couple of years old and don't work in the new code.

 

Really frustrating that customers can add more of a product than is available and don't find out until they click add to cart.

Replies 4 (4)

Ignelis
Shopify Partner
125 15 23

Hi, @glassmaker 

 

Yes, there is a way to limit the product quantity a customer can add to their cart.

 

You can do this by adding this line:

max="{{current_variant.inventory_quantity}}"

 

to your quantity input field in your cart or product template.

 

This will limit the maximum quantity a customer can add to their cart to the available inventory for that product.

 

Let me know how that works for you.

Have a nice day ƪ(˘⌣˘)ʃ
Hire me!
WhatsApp: +37062284670
glassmaker
Tourist
4 0 2

Thank you for your help! Sadly it isn't working putting it in the product template code, even though it looks like it should definitely be working

cduguet
Tourist
3 0 1

What you want is to add the attributes "max" and "data_max" to the input in main-product.liquid like this: 



```
<input
class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
data-cart-quantity="{{ cart_qty }}"
data-min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
min="{{ product.selected_or_first_available_variant.quantity_rule.min }}"
...
data-max="{{product.selected_or_first_available_variant.inventory_quantity}}"
max="{{product.selected_or_first_available_variant.inventory_quantity}}"
...
```

 

Eugene_RF
Tourist
11 0 0

did you ever figure out how to make this work ?