Forked from carolineschnapp/related-products.liquid
Last active
March 2, 2017 23:52
-
-
Save amabes/8e7bf6da533d8d8ae274e683bda1c1e1 to your computer and use it in GitHub Desktop.
Products from Collection — to add to product.liquid
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
<!-- Forked from Caroline Schnapp --> | |
<!-- See this: https://docs.shopify.com/support/your-store/products/can-i-recommend-related-products#finding-a-relevant-collecitons --> | |
{% assign heading = 'Accessories' %} | |
{% assign collection_handle = 'Accessories' %} | |
{% assign same_vendor = false %} {% comment %} Make search more strigent {% endcomment %} | |
{% assign same_type = false %} {% comment %} Make search more strigent {% endcomment %} | |
{% assign collection = collections[:collection_handle] %} | |
{% assign found_a_collection = false %} | |
{% if collection and collection.all_products_count > 1 %} | |
{% assign found_a_collection = true %} | |
{% endif %} | |
{% unless found_a_collection %} | |
{% for c in product.collections %} | |
{% unless c.all_products_count < 2 %} | |
{% assign found_a_collection = true %} | |
{% assign collection = c %} | |
{% break %} | |
{% endunless %} | |
{% endfor %} | |
{% endunless %} | |
{% if found_a_collection %} | |
{% assign current_product = product %} | |
{% capture collection_items %} | |
{% for product in collection.products %} | |
{% unless product.handle == current_product.handle %} | |
{% unless same_vendor and current_product.vendor != product.vendor %} | |
{% unless same_type and current_product.type != product.type %} | |
{% include 'product-grid-item-bs' %} | |
{% endunless %} | |
{% endunless %} | |
{% endunless %} | |
{% endfor %} | |
{% endcapture %} | |
{% assign collection_items = collection_items | trim %} | |
{% unless collection_items == blank %} | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12"> | |
{% unless heading == blank %} | |
<h2 class="h2"> | |
{{ heading }} | |
</h2> | |
{% endunless %} | |
</div> | |
</div> | |
<div class="row"> | |
{{ collection_items }} | |
</div> | |
</div> | |
{% endunless %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment