Limit max quantity of products that can be added to cart

jbekker29
Tourist
9 0 1

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.

 

kawaiilabs.com

0 Likes
JHKCreate
Shopify Partner
2052 334 448

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,

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
0 Likes
jbekker29
Tourist
9 0 1

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

 

0 Likes
JHKCreate
Shopify Partner
2052 334 448

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

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
0 Likes
jbekker29
Tourist
9 0 1
This is what I could find, specifically referencing to the quantities on the cart page
 
{% if type == 'cart' %}
    {% if settings.cart_type == 'page' %}
  <button class="btn btn-square-small qty-adjust qty-minus js-qty__adjust--minus icon-fallback-text" type="button" aria-label="{{ 'cart.general.reduce_quantity' | t }}">
      <span class="fas fa-minus" aria-hidden="true"></span>
      <span class="fallback-text" aria-hidden="true">&minus;</span>
    </button>
    {% endif %}
    <input type="number" name="updates[]" id="updates_{{ item.key }}" class="qty-input cart__product-qty" value="{{ item.quantity }}" min="0" data-id="{{ item.key }}">
    {% if settings.cart_type == 'page' %}
    <button class="btn btn-square-small qty-adjust qty-plus js-qty__adjust--plus icon-fallback-text" type="button" aria-label="{{ 'cart.general.increase_quantity' | t }}">
      <span class="fas fa-plus" aria-hidden="true"></span>
      <span class="fallback-text" aria-hidden="true">+</span>
    </button>
    {% endif %}
  {% endif %}
0 Likes
JHKCreate
Shopify Partner
2052 334 448

In that piece: 

 

 

<input type="number" name="updates[]" id="updates_{{ item.key }}" class="qty-input cart__product-qty" value="{{ item.quantity }}" min="0" data-id="{{ item.key }}">

 

 

add max="{{current_variant.inventory_quantity}}"

and you will have this:

 

 

<input type="number" name="updates[]" id="updates_{{ item.key }}" class="qty-input cart__product-qty" value="{{ item.quantity }}" min="0" max="{{current_variant.inventory_quantity}}" data-id="{{ item.key }}">

 

 

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
0 Likes
jbekker29
Tourist
9 0 1

No change unfortunately

0 Likes
jbekker29
Tourist
9 0 1

Bump

0 Likes