Skip to content

Instantly share code, notes, and snippets.

@sweethoneycode
Last active November 14, 2021 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweethoneycode/e25b911958a844b3941ee9e53aff4799 to your computer and use it in GitHub Desktop.
Save sweethoneycode/e25b911958a844b3941ee9e53aff4799 to your computer and use it in GitHub Desktop.
Color Metafield
{%- comment -%}
variable to hold color
{%- endcomment -%}
{%- assign product_color = product.metafields.my_fields.color -%}
{%- comment -%}
Color Metafield and attributes
{%- endcomment -%}
{%- if product.metafields.my_fields.color -%}
<p><b>Color (default): </b> {{ product.metafields.my_fields.color }} <div style="display: inline-block; background-color:{{ product.metafields.my_fields.color }};width:10px;">&nbsp;</div></p>
<p><b>Color (red): </b> {{ product.metafields.my_fields.color.value.red }}</p>
<p><b>Color (blue): </b> {{ product.metafields.my_fields.color.value.blue }}</p>
<p><b>Color (green): </b> {{ product.metafields.my_fields.color.value.green }}</p>
{%- endif -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment