Re: How to prevent adding items in cart page when the available stock is exceeded

How to prevent adding items in cart page when the available stock is exceeded

Mohamed_Evisu
Tourist
9 1 1

Hello,

I'd like to know how to prevent adding items when the available stock is exceeded, as it currently allows adding items beyond the stock limit but gives a warning when decreasing the quantity.
 
 
01.jpg02.jpg
Replies 3 (3)

Guleria
Shopify Partner
3422 681 965

Hello,

 

You need to get the inventory with each product

{% if current_variant.inventory_quantity > 0 and current_variant.inventory_management == 'shopify' %}
    <p>Stock: {{ current_variant.inventory_quantity }}</p>
  {% endif %}

 Now from next to it use  the JS to build the logic a/to your need.

 

Thanks

- If helpful then please Like and Accept Solution.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com
- Try GEMPAGES a great page builder
Mohamed_Evisu
Tourist
9 1 1

Thanks for replying, but please where should I add this code??

is it in (main-cart-items.liquid) or other? I'm using Dawn theme.

Gadgetopia2024
Visitor
2 0 0

Did you find the solution?