Shopify themes, liquid, logos, and UX
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.
Solved! Go to the solution
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!
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.
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!
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!
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.
Please send me the code to display sizes. I will check it.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024