How can I display product quantity on Ella theme homepage?

Topic summary

Goal: mostrar la cantidad total de inventario por producto en la página de inicio del tema Ella para crear sensación de escasez.

Intento inicial: código Liquid en product-cards.liquid que suma inventory_quantity de cada variante termina mostrando 0 para todos los productos.

Sugerencia: reasignar “total” en cada iteración del bucle de variantes. Probado por otra persona y funciona en su tienda, pero el autor sigue viendo 0 en homepage y página de colección.

Causa probable: en la página de inicio no se tiene acceso directo al objeto product; el código funciona en la página de producto, donde product está disponible, pero no en secciones de inicio/colección.

Recomendación: acceder a los productos vía collection.products en la homepage/tienda, iterar sobre cada producto y, dentro, iterar sus variantes para sumar inventory_quantity. En la página de producto, usar directamente product.

Estado: sin implementación verificada final; el problema permanece abierto.

Notas técnicas: Shopify Liquid, objetos product y collection, variantes, campo inventory_quantity. Los fragmentos de código son centrales para comprender el tema.

Summarized with AI on January 26. AI used: gpt-5.

Hi,

I need to enter the quantity of the product

to create scarcity on the store homepage.

I’ve read other articles from others using other

themes to do this by putting small code,

how can I do it with Ella?

What do you recommend?

UPDATE

I entered this in product-cards.liquid but

I can’t get the correct number of the quantity

to appear because for all it then remains on 0!


{% assign total=0 %}
{%for variant in product.variants %}
{% capture i %}{{ total | plus:variant.inventory_quantity }}{%endcapture%}
{% assign total = i %}
{%endfor%}
**Disponibilità:** **{{ total }}**

Thanks

Hey!
Try

{% assign total = 0 %}
{% for variant in product.variants %}
  {% assign total = total| plus: variant.inventory_quantity %}
{% endfor %}

I tried your code snippet on my own store, and I also got zero. There is a possibility that the variables are not keeping the values in some way. Hopefully, reassigning the values after each iteration works!

EDIT: I updated the solution, and tested it on my own store. It works for me.

Thanks,

I tried the solution, but it still shows 0, probably

this could work in the product tab, but I need the

quantity indicator in the homepage and shop page.

True. You need access to the product object. If its the home page, you need to access the object through collection like collection.products. Then run a loop through the collection.products. If its the product page, all you have direct access to the product object.