product.options_by_name['Colour'] question?

Chris_Sydney
Shopify Partner
19 0 3

Hey, 

I am looking at the following filter:

                  {% for color_option in product.options_by_name['Colour'].values %}
                   <option>{{ color_option }}</option>
                  {% endfor %}
I am wondering If anything is accessable via this? I am trying to pull the {{ variant.featured_media }} or  even the {{ variant.id }}... Is this just limited to outputting the color_option variable? 
 
Cheers,
 
Chris 
Reply 1 (1)
LitExtension
Shopify Partner
1990 331 407

Hi @Chris_Sydney,

For is displaying values, so you can't call with variant.

You need to change the code:

{%- assign shown_list = '' -%}
{%- if product.options_by_name['Colour'].name == 'Colour' -%}
{%- for variant in product.variants -%}
{%- assign option_handle = variant.options[option_index] -%}
{%- unless shown_list contains option_handle -%}

// show content, ex: {{ variant.featured_media }}

{%- assign shown_list = shown_list | join: ',' -%}
{%- assign shown_list = shown_list | append: ',' | append: option_handle -%}
{%- assign shown_list = shown_list | split: ',' -%}
{%- endunless -%}
{%- endfor -%}
{%- endif -%}

Hope it helps 

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

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!