Skip to content

Instantly share code, notes, and snippets.

@projoomexperts
Created May 11, 2016 18:50
Show Gist options
  • Save projoomexperts/cb89ca5532435fa63450d4e481b537a6 to your computer and use it in GitHub Desktop.
Save projoomexperts/cb89ca5532435fa63450d4e481b537a6 to your computer and use it in GitHub Desktop.
Shopify size variant label in collection page under product.
<ul class="sizelist">
{% for option in product.options %}
{% if option == 'Size' %}
{% assign index = forloop.index0 %}
{% assign colorlist = '' %}
{% assign color = '' %}
{% for variant in product.variants %}
{% capture color %}
{{ variant.options[index] }}
{% endcapture %}
{% unless colorlist contains color %}
{% if variant.available %}
<li id="{{ variant.id }}" title="{{ variant.inventory_quantity }} In Stock" class="avactive"><a href="{{ product.url | within: collection }}?variant={{ variant.id }}">{{ color | downcase }}</a></li>
{% else %}
<li id="{{ variant.id }}" title="Out of Stock" class="notactve" >{{ color | downcase }}</li>
{% endif %}
{% capture tempList %}
{{colorlist | append: color | append: " " }}
{% endcapture %}
{% assign colorlist = tempList %}
{% endunless %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment