Last active
September 11, 2023 17:37
-
-
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.
This file contains hidden or 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
<!-- 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