Created
January 30, 2024 08:38
-
-
Save liamgriffin/1cb6e8c22b8827da0c95aab2e3116943 to your computer and use it in GitHub Desktop.
Color Swatches - Variant Picker and Options
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_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