Created
March 21, 2014 17:12
-
-
Save kyleaparker/9691004 to your computer and use it in GitHub Desktop.
Shopify: Show number of colors available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for option in product.options %} | |
{% if option contains "Color" %} | |
{% assign optionName = "option" | append: forloop.index %} | |
{% assign colors = product.variants | map: optionName %} | |
{% assign colorsFiltered = '' %} | |
{% for colorOption in colors %} | |
{% unless colorsFiltered contains colorOption %} | |
{% assign colorsFiltered = colorsFiltered | append: ', ' | append: colorOption %} | |
{% endunless %} | |
{% endfor %} | |
{% endif %} | |
{% endfor %} | |
{% assign uniqueColors = colorsFiltered | remove_first: ', ' | split: ', ' %} | |
{% if product.options contains "Color" %}{{ uniqueColors.size }} colors available{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment