Skip to content

Instantly share code, notes, and snippets.

@liamgriffin
Created January 30, 2024 08:38
Show Gist options
  • Save liamgriffin/1cb6e8c22b8827da0c95aab2e3116943 to your computer and use it in GitHub Desktop.
Save liamgriffin/1cb6e8c22b8827da0c95aab2e3116943 to your computer and use it in GitHub Desktop.
Color Swatches - Variant Picker and Options
{%- for option in product.options_with_values -%}
{%- liquid
assign swatch_count = option.values | map: 'swatch' | compact | size
assign picker_type = block.settings.picker_type
if swatch_count > 0 and block.settings.swatch_shape != 'none'
if block.settings.picker_type == 'dropdown'
assign picker_type = 'swatch_dropdown'
else
assign picker_type = 'swatch'
endif
endif
-%}
{%- if picker_type == 'swatch' -%}
<fieldset class="js product-form__input product-form__input--swatch">
<legend class="form__label">
{{ option.name }}:
<span data-selected-swatch-value="{{ option.name }}">
{{- option.selected_value -}}
</span>
</legend>
{% render 'product-variant-options',
product: product,
option: option,
block: block,
picker_type: picker_type
%}
</fieldset>
{%- endfor -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment