I want to add the number of available stock to each variant label in the Dawn theme.
So example S would look like S (10)
I want to add the number of available stock to each variant label in the Dawn theme.
So example S would look like S (10)
Hi Alex. Can you please show through a screenshot what you want?
Try in the main-product.liquid section file. Scroll down to the {%- when ‘variant_picker’ -%} part and update the code to include ({{ product.variants[index].inventory_quantity }}) after the {{value}} in the label and add a index variable:
{%- when 'variant_picker' -%}
{%- unless product.has_only_default_variant -%}
{%- if block.settings.picker_type == 'button' -%}
Hey thanks Alan! unfortunately{{ product.variants[index].inventory_quantity }} is out of scope here so it returns empty. The way they’ve constructed the variant options is a proper pain in Dawn as you can’t access variant data easily ![]()
And if you stick a {% for variant in product.variants %} around it as it’s already in a loop you get recursion… pain
I managed to get it working with {{ product.variants[forloop.index0].inventory_quantity }}
Thanks so much!