Skip to content

Instantly share code, notes, and snippets.

@hhayrapetyan
Last active May 22, 2019 16:39
Show Gist options
  • Save hhayrapetyan/bb697ae50169da8ba500 to your computer and use it in GitHub Desktop.
Save hhayrapetyan/bb697ae50169da8ba500 to your computer and use it in GitHub Desktop.
Shopify Venture Theme Related products snippet
@dgm52
Copy link

dgm52 commented Mar 3, 2016

Great! Thank you mate!

@SDTEEJAY
Copy link

That helped me out also, Thanks!

@minafad
Copy link

minafad commented Apr 29, 2016

good

@bmulholand
Copy link

You've saved me a great deal of time. Thanks for sharing this!

@websitefavourite
Copy link

Thanks for sharing, works great!

@sinans11
Copy link

Hi, Can anyone help? The code works great accept the spacing between the title and the related products is too wide. How can I make the spacing less?

Would really appreciate any help.
thanks

@satquiel
Copy link

Quick question, would you know how i can change the below to make it show a maximum of only 4 related products?

{% if settings.display_related_products %}
{% capture limit %}{{ settings.products_per_row | plus: 1 }}{% endcapture %}

{% if collection and collection.all_products_count > 4 %}
  {% assign col = collection.handle %}
{% else %}
  {% assign col = product.collections.last.handle %}
{% endif %}

{% for tag in product.tags %}
  {% if tag contains 'meta-related-collection-' %}
    {% assign col = tag | remove: 'meta-related-collection-' %}
    {% assign collection = collections[col] %}
    {% capture limit %}{{ collection.products_count | plus: 1 }}{% endcapture %}
  {% endif %}
{% endfor %}
  
{% if col and collections[col].all_products_count > 0 %}
  <br class="clear" />
  <br class="clear" />
  <h4 class="title center">{{ 'products.product.related_items' | t }}</h4>

{% assign skip_product = product %}
  {% assign products = collections[col].products %}
  {% assign products_per_row = settings.products_per_row %}
  {% include 'product-loop' with settings.product_sidebar %}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment