Skip to content

Instantly share code, notes, and snippets.

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 shopifypartners/d424c4dadc5a4bb58ef69b8bf94eb767 to your computer and use it in GitHub Desktop.
Save shopifypartners/d424c4dadc5a4bb58ef69b8bf94eb767 to your computer and use it in GitHub Desktop.
How to Build a Customizable Related Products Section | https://www.shopify.com/partners/blog/related-products
<div class="product-recommendations" data-product-id="{{ product.id }}" data-limit="4">
{%- if recommendations.products_count > 0 -%}
<h2>You may also like</h2>
<ul>
{%- for product in recommendations.products -%}
<li class="product">
<a href="{{ product.url }}">
<img class="product__img" src="{{ product.featured_image | img_url: '300x300' }}" alt="{{ product.featured_image.alt }}" />
<p class="product__title">{{ product.title }}</p>
<p class="product__price">{{ product.price | money}}</p>
</a>
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment