Forked from joe-dempsey/Shopify add color swatches to collection pages.txt
Created
January 2, 2020 22:28
-
-
Save mattmagi/e9026eb198074ec686eeef3ff0313e17 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