Dawn: product.first_available_variant.inventory_quantity not working on products with no variants

I use Dawn - and I use the inventory status section (build in).
I have set threshold to 5 and enabled showing inventory count on the shop.

Now the tricky thing is:

  • This works perfectly on products with variants. It shows and updates the quantity as expected.
  • However - on product without variants, the quantity never shows. It is like product.first_available_variant.inventory_quantity is empty.
  • Even more strange: In the Theme editor it DOES work on products without variants - but live in shop it does not work.

I simply can’t see how to solve this.

Here is the default code:

{%- if product.selected_or_first_available_variant.inventory_quantity

                          <= block.settings.inventory_threshold

                      -%}

                        <span class="svg-wrapper" style="color: rgb(238, 148, 65)">

                          {{- 'icon-inventory-status.svg' | inline_asset_content -}}

                        </span>

                        

                       {%- if block.settings.show_inventory_quantity -%} 

                        

                        {{- 'products.product.inventory_low_stock_show_count' | t: quantity: product.selected_or_first_available_variant.inventory_quantity -}} 

                      {%- else -%} 

                        {{- 'products.product.inventory_low_stock' | t -}}

                       {%- endif -%}

And here is link to a product that does not work (please choose Danish language - not English):

And here you can see a variant product working flawlessly:

It seems product.first_available_variant.inventory_quantity is not working on non-variant products outside the theme editor, but I don’t understand why, as this should be the way to fetch quantity also from non-variant products.

Here is a screenshot from the Theme editor where it DOES work:

I tried using product.first_available_variant.inventory_quantity instead - but that does not change anything.

I hope someone can help here.

Use product.variants.first.inventory_quantity instead of product.first_available_variant.inventory_quantity.
It works reliably for both single- and multi-variant products, fixing the issue where inventory doesn’t show on non-variant items.

Sorry - that didn’t work. So strange it works in the theme editor and not in the shop.

I found out, that when I preview it with the template name as query parameter, it works. But without - it doesn’t.

However live the product uses the same product template.

Working with template name as query parameter:

Nope, it’s not the same template:

Thanks. Saved me there.