Skip to content

Instantly share code, notes, and snippets.

@jshaw
Last active September 11, 2023 17:37
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 jshaw/8c993393dc3eec6c10d03819a164bbc4 to your computer and use it in GitHub Desktop.
Save jshaw/8c993393dc3eec6c10d03819a164bbc4 to your computer and use it in GitHub Desktop.
Using metafields and collections for custom product varients when using unique products, not default product varient behaviour.
<!-- Using metafields and collections for custom product varients when using unique products, not default product varient behaviour. -->
{% liquid
assign product_variants = product.metafields.custom.product_variant_collection.value.products
%}
{% for variant in product_variants %}
<!-- so we don't show the current product in the varient list, we do a quick compaire between the current product we are on the PDP and the varient ID in the loop -->
{% if product.id != variant.id %}
<li class="product-details__panel-variant-item">
<a
href="{{ variant.url }}"
aria-label="{{ variant.title }}"
title="{{ variant.title }}">
<div class="product-details__panel-variant-image-wrapper">
{{ variant.featured_image
| image_url: width: 100
| image_tag:
class: "product-details__panel-variant-image",
loading: "eager" }}
</div>
</a>
</li>
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment