Skip to content

Instantly share code, notes, and snippets.

@jshaw
Last active September 11, 2023 17:37
Show Gist options
  • Save jshaw/8c993393dc3eec6c10d03819a164bbc4 to your computer and use it in GitHub Desktop.
Save jshaw/8c993393dc3eec6c10d03819a164bbc4 to your computer and use it in GitHub Desktop.

Revisions

  1. jshaw revised this gist Sep 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion product-variant-list.liquid
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <!-- 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
    assign product_variants = product.metafields.custom.product_variant_collection.value.products
    %}

    {% for variant in product_variants %}
  2. jshaw renamed this gist Sep 11, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. jshaw revised this gist Sep 11, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions .liquid
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <!-- 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
    %}
  4. jshaw created this gist Sep 11, 2023.
    23 changes: 23 additions & 0 deletions .liquid
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    {% liquid
    assign product_variants = product.metafields.custom.product_variant_collection
    %}

    {% 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 %}