Duplicate available sizes on product grid

Theme: DEBUT

Website: PPFclothing.com

Password: PPF

Hello,

Recently I have added variants to some of my products. However, this brings up the issue that the available sizes on the product grid show up twice if there are two variants. Here is an example:

Would someone advise me on how I would go about fixing this?

Thank you.

1 Like

@Ljkeos

sorry for that issue.

i have check your whole store but i can’t see that issue its all working fine!

if you have issue please mention page url

Please send me the code to display sizes. I will check it.

@LitExtension

Here is the code for displaying sizes on the product grid in product-card-grid.liquid:

{% if collection.handle == "unique-hoodies" or collection.handle == "t-shirts" or collection.handle == "4x-collection" or collection.handle == "living-in-the-wrong-time"%}
 
    

      {% for option in product.options %}
        {% if option == 'Size' %}
            {% if product.options_with_values[0].name=="Size" %}
                {% for variant in product.variants %}
 
                  {{ variant.option1  }}
 
                {% endfor%}
            {% elsif product.options_with_values[1].name=="Size" %}
                {% for variant in product.variants %}
 
                  {{ variant.option2  }}
 
                {% endfor%}
            {% else %}
                {% for variant in product.variants %}
 
                  {{ variant.option3  }}
 
                {% endfor%}
            {% endif %}
 
        {% endif %}
     {% endfor %}
    

  {% endif %}
  {% include 'product-price-listing', product: product, show_vendor: show_vendor %}

Let me know if you find a solution!

Please send me the code to display sizes. I will check it.

Please change the code:
{% for option in product.options %}
{% if option == β€˜Size’ %}
{% assign option_index = forloop.index0 %}
{% assign values = β€˜β€™ %}
{% for variant in product.variants %}
{% assign value = variant.options[option_index] %}
{% unless values contains value %}
{% assign values = values | join: β€˜,’ %}
{% assign values = values | append: β€˜,’ | append: value %}
{% assign values = values | split: β€˜,’ %}
{{ value | escape }}
{% endunless %}
{% endfor%}
{% endif %}
{% endfor %}
Hope it helps!

1 Like

Awesome-- this worked, thank you!

For future reference, here is the code to display available sizes under products in the product grid:

{% if collection.handle == "unique-hoodies" or collection.handle == "t-shirts" or collection.handle == "4x-collection" or collection.handle == "living-in-the-wrong-time"%}
 
    

      {% for option in product.options %}
{% if option == 'Size' %}
{% assign option_index = forloop.index0 %}
{% assign values = '' %}
{% for variant in product.variants %}
{% assign value = variant.options[option_index] %}
{% unless values contains value %}
{% assign values = values | join: ',' %}
{% assign values = values | append: ',' | append: value %}
{% assign values = values | split: ',' %}
{{ value | escape }}
{% endunless %}
{% endfor%}
{% endif %}
{% endfor %}
    

  {% endif %}
  {% include 'product-price-listing', product: product, show_vendor: show_vendor %}

Place it at the end of product-card-grid.liquid in snippets. Of course, you will need to change the collection names to collections you want the sizes to show.