Display Product variant weight for option2 (not selected)

Hi team,

Ive searched everywhere for the answer to this question. Im wanting to display both variant weights on the product page and not just the selected variant.

{{ product.variants.first.weight | weight_with_unit }} works for the selected variant but how do I get the second one? Any ideas?

Thank you in advance!

Kelly

Hi @Kelly31 ,

You need to for variants:
{%- for variant in product.variants -%}
{{ variant.weight | weight_with_unit }}
{%- endfor -%}
It will show all variant and weight.
If you only want to show the 2nd variant, refer code:
{%- for variant in product.variants -%}
{%- if forloop.index == 2 -%}
{{ variant.weight | weight_with_unit }}
{% break %}
{%- endif -%}
{%- endfor -%}
Or
{{ product.variants[1].weight | weight_with_unit }}

Hope it helps!

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

Hello, can i show the shipping cost according to variant weight? and put them on the product page, can you please help me with this?