Solved

Duplicate available sizes on product grid

Ljkeos
Excursionist
31 0 13

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:

Screen Shot 2021-07-23 at 11.05.50 AM.png

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

Thank you.

Accepted Solution (1)
LitExtension
Shopify Partner
4860 1001 1132

This is an accepted solution.

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!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

View solution in original post

Replies 6 (6)

KetanKumar
Shopify Partner
36839 3635 11972

@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 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

LitExtension
Shopify Partner
4860 1001 1132

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

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Ljkeos
Excursionist
31 0 13

@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"%}
 
    <p>
      {% 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 %}
    </p>
  {% endif %}
  {% include 'product-price-listing', product: product, show_vendor: show_vendor %}

</div>

Let me know if you find a solution!

LitExtension
Shopify Partner
4860 1001 1132

This is an accepted solution.

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!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Ljkeos
Excursionist
31 0 13

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"%}
 
    <p>
      {% 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 %}
    </p>
  {% endif %}
  {% include 'product-price-listing', product: product, show_vendor: show_vendor %}

</div>

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.

LitExtension
Shopify Partner
4860 1001 1132

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

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify