Created
June 4, 2018 12:29
-
-
Save joe-dempsey/6ef2e9e047e8e95fde0342b7667b8289 to your computer and use it in GitHub Desktop.
Shopify add color swatches/dots to collection pages.
This file contains hidden or 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
{% capture option_titles %}Color,color,Colour,colour{% endcapture %} | |
{% assign option_titles = option_titles | split:',' %} | |
{% for option in product.options %} | |
{% if option_titles contains option %} | |
{% capture option_index %}option{{ forloop.index }}{% endcapture %} | |
{% assign option_values = product.variants | map: option_index | uniq %} | |
{% if option_values.size != 1 %} | |
{% for opt in option_values %} | |
<div style="background-color:{{ opt | downcase }};" class="option_circles"></div> | |
{% endfor %} | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
<style> | |
.option_circles { | |
height: 25px; | |
width: 25px; | |
background-color: #bbb; | |
border-radius: 50%; | |
display: inline-block; | |
border:1px solid #ccc; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment