How can I fix variant image swatches showing the same color for all variants?

Hello there!

I am currently working on creating colour swatches using variant images and am coming across an issue where the swatch is returning the variant image for all variants (colour and size) rather than the requested one. As a result the image swatch displays the first variant image - which is the same for all colours.

I’m a bit of a newbie so not sure where I am going wrong. Would be grateful for any help/suggestions.

This is a preview of the product page: https://lktmg7oe2kzf9afu-54300377279.shopifypreview.com/products/lighthouse-outback-full-length-ladies-waterproof-raincoat?_pos=2&_sid=6f476b6f0&_ss=r

{%- if is_color -%}
              
              {%- liquid
                assign option_index = forloop.index0
                assign values = ''
                assign max_count = settings.color_swatches_max_items
                assign has_color_option = true
              -%}
              
              
              

            
            {%- else -%}
              
            {%- endif -%}

you can try this one

{% if forloop.first == true %}{% endif %}

if this :backhand_index_pointing_up: was not working try this :backhand_index_pointing_down:


Hi @Avi_choudhary ,

Unfortunately these do not seem to work.

The first suggestion returns a no image placeholder.

The second returns just a single image url for each colour variant however they are all for the same colour (ie, they all appear as black, rather than the correct image for each one).

Thanks for your help though!

can we connect on skype: live:ramchandra3938

you can direct message me

1 Like