Need Cart Line Item Inventory Count Liquid

We are trying to show a message under each line item in the cart for the customer.

If the customer’s cart quantity for a line item is more than the item inventory available stock, the message should appear. Does anyone know the correct liquid code? “cart.item_count” does the job, but for the total including every item.

Hi @Patchcollection ,

You can use the following code:

{% if item.variant.inventory_quantity > -1 %}
                      {% if item.quantity > item.variant.inventory_quantity %}
                    	
                      {% endif %}
{% endif %}

Ex:

Hope it helps!

Great. Works as intended. Thank you for your help.

Hello how can I do it for the product and the collection

Hello how can I do it for the product and the collection?

Hi @Aleon ,

You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.

https://community.shopify.com/post/1775242

Hi, i want to show stock quantity under quantity, can you help me, thank you very much, have a nice day

Store: https://nigahimastyle.com/

hi, i want to show stock quantity under quantity, can you help me, thank you very much, have a nice day

Hi @Toland ,

You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.

https://community.shopify.com/topic/1784163

This is how it shows

Unidades disponibles {{ product.selected_or_first_available_variant.inventory_quantity }}

and if it works for you, validate the input before adding to the cart

and it would be something like this