All things Shopify and commerce
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.
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.
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
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}}"
...
```
did you ever figure out how to make this work ?
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