need help with the code for adding sizes under a collection on home page

I want to put these sizes

on the home page so can some help me with the code https://6z4l9rydmixlbfyz-57857638606.shopifypreview.com

1 Like

@wear4wealth

{% comment %}
Create a snippet and paste below code and assign where you want show size variants. 
{% endcomment %}

{% assign variantCount = product.variants | size %}
{% if product.available and variantCount > 0 %}

{% for option in product.options %}
{% assign is_size = false %}
{% assign downcased_option = option | downcase %}

{% if downcased_option contains 'size' %}
{% assign option_index = forloop.index0 %}
{% assign option_count = 0 %}
{% assign values = '' %}

{% for variant in product.variants %}
{% assign value = variant.options[option_index] %}
{% unless values contains value %}

{% if option_count > 0 %}
{% assign values = values | join: '|' | append: '|' %}
{% endif %}
{% assign values = values | append: value %}
{% assign values = values | split: '|' | sort %}
{% assign option_count = values | size %}

{% if variant.available %}
{% if option_count <= 6 %}

{{ value }}

{% assign option_count = option_count | plus : 1 %}

{% endif %}
{% endif %}

{% endunless %}
{% endfor %}

{% if values.size >= 6 %}

...

{% endif %}

{% endif %}

{% endfor %}

{% endif %}

how to called this fine whiner are you want

{% include "snippet-name " %}

@KetanKumar @What file do I put it in ?

@KetanKumar is there a way you can make the size buttons look like this with the code?