Fast delivery icon showing to all the variation despite of 0 quantity.

Topic summary

Issue: A “fast delivery” (thunder) icon should appear only on in-stock size variants, but it shows for all variants, including those with 0 inventory (e.g., XL, 2XL, 3XL, 4XL).

Details: The Liquid snippet checks product.variants[forloop.index0].inventory_quantity > 1 inside a label within an options loop. A screenshot is referenced; a code snippet is central to understanding.

Diagnosis: The response explains the loop context is likely wrong—looping over product.options is not the same as looping over product.variants. The code probably reads the first or currently selected variant’s inventory for every option, causing incorrect icon display.

Suggested checks and next steps:

  • Manually select an out-of-stock variant and reload; if icons disappear, it confirms the mismatch.
  • Implement JavaScript to update icons dynamically as customers select options, since Liquid only renders the initially loaded variant.
  • Provide surrounding code and store/theme context for accurate debugging.

Status: No finalized fix; discussion remains open pending more context and potential custom implementation.

Key terms: variant (specific option combination), options loop vs variants loop, inventory_quantity.

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


{%- if product.variants[forloop.index0].inventory_quantity > 1 -%}
:high_voltage: {{ value | escape }}
{%- else -%}
{{ value | escape }}
{%- endif -%}

I’ve used this code to show the thunder icon on variation boxes with inventory above 0. But icons are still showing with inventory 0. Below is the reference screenshot. here everything is fine but XL, 2XL, 3XL, 4XL are o in inventory.

Hi @tanmmetsingh Because it’s very likely the variant isn’t what you think it is.

If your inside a product.options loop that is not the same as looping over variants.

So more than likely your just outputting the first or currently selected variants inventory, and not actually comparing ALL inventory for ALL variant options.

You can quickly confirm somethings by selecting options for a variant that should be out of stock then reloading the page, if all the icons disappear that’s the core culprit.

But beyond that it’s impossible to tell without going over the context of the code that surrounds what you’ve shared here.

Even then this will generally only work with the loaded selected variant on the customer side, so as they choose options the icons will stay unless you also work with javascript.

If you need this debugged and customized to be dynamic then contact me by mail for services.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Contact info in signature.