Skip to content

Instantly share code, notes, and snippets.

@odessy
Created November 27, 2024 15:47
Show Gist options
  • Save odessy/246326e03efae22a26aade1b2ab48750 to your computer and use it in GitHub Desktop.
Save odessy/246326e03efae22a26aade1b2ab48750 to your computer and use it in GitHub Desktop.
Swatch colors available
{%- liquid
assign swatch_option = nil
if settings.swatches_enable
assign swatch_translation = 'general.swatches.color' | t
assign swatch_labels = swatch_translation | append: ',' | split: ','
for label in swatch_labels
assign sanitized_label = label | lstrip | rstrip
if product.options_by_name[sanitized_label].values.size > 0
assign swatch_option = product.options_by_name[sanitized_label]
break
endif
endfor
endif
-%}
{%- if swatch_option != blank -%}
<div class="grid__swatch__container">
<p class="grid__swatch__placeholder_custom">{{ 'collections.general.swatches_with_count' | t: count: swatch_option.values.size }}</p>
</div>
{%- endif -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment