Hi Everyone,
I’m trying to show weight each of my variant how can I do that??
This is code I used.
{%- for value in option.values -%}
{% include 'product-get-options-res-status' with option_index0: option_index0 %}
{{ value | replace: '<', '<' | replace: '>', '>' }}{{ product.variants.weight | weight_with_unit }}
{%- endfor -%}
for the weight I use this one {{ product.variants.weight | weight_with_unit }}
and here’s my result
Hi @limraitec ,
If you want to display for each variant, you need to use for ‘product.variants’.
Please change all code:
{%- for variant in product.variants -%}
{%- assign option_handle = variant.options[option_index] -%}
{%- unless shown_list contains option_handle -%}
{% include 'product-get-options-res-status' with option_index0: option_index0 %}
{{ option_handle | replace: '<', '<' | replace: '>', '>' }}{{ variant.weight | weight_with_unit }}
{%- assign shown_list = shown_list | join: ',' -%}
{%- assign shown_list = shown_list | append: ',' | append: option_handle -%}
{%- assign shown_list = shown_list | split: ',' -%}
{%- endunless -%}
{%- endfor -%}
Hope it helps!
Hello LitCommerce, thanks for the solution but the issue with this is it only shows the weight of the first SKU.
For my desire output I want to show the weight of each variant
It should be
Estrela 5kg
Frisa 8kg
Minverva 10kg
Hi @limraitec ,
Please change code:
{%- assign option_index = forloop.index0 -%}
{%- for variant in product.variants -%}
{%- assign option_handle = variant.options[option_index] -%}
{%- unless shown_list contains option_handle -%}
{% include 'product-get-options-res-status' with option_index0: option_index0 %}
{{ option_handle | replace: '<', '<' | replace: '>', '>' }}{{ variant.weight | weight_with_unit }}
{%- assign shown_list = shown_list | join: ',' -%}
{%- assign shown_list = shown_list | append: ',' | append: option_handle -%}
{%- assign shown_list = shown_list | split: ',' -%}
{%- endunless -%}
{%- endfor -%}
Hope it helps!
Hello LitCommerce,
Thanks for this Iapplied the code you provide but i still have same issue with the weight
you can check the output here
https://t-dev-store.myshopify.com/collections/wholesale
(password: thaboh)