Limit max quantity of products that can be added to cart

Hi all

How can I limit the max amount of a product someone can add, eg. If I want 8 of product A, but there is only 5 available in inventory then the quantity box needs to change to the max available quantity instead.

I’ve been raking my brain on how to do this, any help is appreciated.

Hey!

How proficient are you in Liquid programming as there is a way to set a max Qty to be displayed inside the quantity field but you need to find the Quantity Div Element

Happy to assist further should you need any help!

Best,

I’m comfortable with liquid, if you could help I appreciate

First step would be locating your quantity input field, it could be in the cart or product template. Let us know once you find this

This is what I could find, specifically referencing to the quantities on the cart page

{% if type == ‘cart’ %}
{% if settings.cart_type == ‘page’ %}




{% endif %}

{% if settings.cart_type == ‘page’ %}


+

{% endif %}
{% endif %}

In that piece:


add max=“{{current_variant.inventory_quantity}}”

and you will have this:


1 Like

No change unfortunately

Bump

This worked for me! THANK YOU!