Select only first variant of particular color in shopify

46 Views Asked by At

I have created below code where i can show the variants as a seperate block in collection page .

{% for option in product.options %}
  {% if option == "Color" or option == "Colour" %}
    {% assign index = forloop.index0 %} 
    {% for variant in product.variants %}
         {% render 'product-block',
              product: variant,
              
              product_class: product_class,
              i: forloop.index,
             t : ptitle,
              lazy_images: lazy_images,
              show_vendor: section.settings.show_vendor
            %}     
    {% endfor %}
  {% endif %}
{% endfor %}

This is working fine . But i have two variant options size and color . As we have 3 sizes and 8 colors so now with above codes its showing me 24 variants in collection page . I need to show only the color options so total 8 . Like first size of each color options. Is that possible ?

0

There are 0 best solutions below