james0r
6/18/2019 - 12:06 AM

Code Sample

Code Sample

{%- if product.variants.size > 1 and product.options_with_values[0].name == swatch_variant_label and use_master_image == false -%}
	{% assign list_swatch_override = product.metafields.c_f.swatch_override | split: ';' %}
	<div class="swatch">

    {% assign already_added = ';' | split: ';' %}
    {% for variant in product.variants %}
      {% assign current_item = variant.option1 | split: ';' %}
      {% assign last_added_item = already_added | last %}
      {%- if last_added_item != variant.option1 -%}
        {% assign already_added = already_added | concat: current_item %}

        {%- comment %} Liquid logic for swatch override {% endcomment -%}
    		{% assign swatch_img = variant | img_url: '250x' %}
    		{%- for item in list_swatch_override -%}
    			{% assign swatch_override = item | split: '=' %}
    			{% assign defined_sku = swatch_override[0] | strip %}
    			{%- if defined_sku == variant.sku -%}
    				{% assign swatch_img = swatch_override[1] | strip %}
    				{%- break -%}
    			{%- endif -%}
    		{%- endfor -%}
        {%- comment %} Liquid logic for swatch override {% endcomment -%}
        {% if variant.sku != '' %}
  			<a class="swatch__item-shell" href="{{ variant.url }}">
  				{%- comment %} Default to the variant image, if no swatch override image defined {% endcomment -%}
  				<div class="swatch__item swatch__item--default" style="background-image: url({{ swatch_img }})" title={{ variant.title }}>
  				</div>
  			</a>
        {% endif %}
  		{% endif %}
	{%- endfor -%}
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
		<a href="" class="swatch__item-shell swatch__item-shell--empty"></a>
	</div>
{%- endif -%}

	<a href="{{ product.url }}">
		<p>{{ product.title }}</p>

	  <div style='margin-bottom:-24rem;margin-top:-1rem;'class='jdgm-widget jdgm-preview-badge' data-id='{{ product.id }}'>{{ product.metafields.judgeme.badge }}</div>

	{%- if product.price_varies -%}
	  <p>{{ product.price_min | money }} - {{ product.price_max | money }}</p>
	{%- else -%}
	  <p>{{ product.price_max | money }}</p>
	{%- endif -%}
	</a>
</div>