Skip to content

Instantly share code, notes, and snippets.

@nicolemackin
Last active September 1, 2020 03:06
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicolemackin/e16032afec67c32c82936ac3d080f0bb to your computer and use it in GitHub Desktop.
Save nicolemackin/e16032afec67c32c82936ac3d080f0bb to your computer and use it in GitHub Desktop.
Related products section for Debut
@stevenuniverseonshopify
Copy link

Hey Nicole,

Is there a way to set the image size to a smaller size? I looked through your code but couldn't find an obvious piece to change.

Appreciate the great free resource, thanks!

@wealllikedan
Copy link

Hi Nichole,

I am getting an error.

Line 132 — Liquid syntax error: Unknown tag 'schema'

Can you help me?

Thank you

@grounded042
Copy link

grounded042 commented Feb 14, 2017

@thomasgheorghe
Copy link

I'm trying to find {% section 'product-template' %} in the product-template.liquid file to place {% section 'related-products' %} under. However, I can't find {% section 'product-template' %}. What line is {% section 'product-template' %} on in the product-template.liquid file? I do see {% section 'product-template' %} in the product.liquid file though. Should it not be there? Any suggestions? Thank you!

@zanusaurelius
Copy link

Hi, at step 7 it explains how to add randomness to the recommended related products, but the explanation is for a snippet. How do we add it for a section? These are the snippet instructions if it helps at all:

Step 7. Configuring (optional) and adding randomness

At the top of the snippet file, you'll find this:

{% assign number_of_related_products_to_show = 3 %}
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}

By editing the above lines of code, you can change: heading text, number of product recommendations, and size of the recommended product image. Valid values for size are: 'small', 'compact' or 'medium'. How big are those sizes? Check here.

If you are a designer, and are thinking of integrating related products in a theme, consider creating settings on the Customize theme page to toggle recommendations on and off.

You can output all products from the relevant collection and pick a limited number of products randomly using this jQuery plugin: https://github.com/carolineschnapp/jquery-pick/blob/master/jquery.pick.js

If you do that, remove the limit from the related-products.liquid snippet.

Change this line:

{% for product in collection.products limit: number_of_related_products_to_fetch %}

To this:

{% for product in collection.products %}

Then, upload the file jquery.pick.js to your Theme Assets. (You will find that file here: https://github.com/carolineschnapp/jquery-pick/blob/master/jquery.pick.js)

Then, add the following code at the bottom of your related-products snippet:

{{ 'jquery.pick.js' | asset_url | script_tag }}

<script type="text/javascript" charset="utf-8"> // li').pick(howMany); }); //]]> </script>

@scootcho
Copy link

You still need to perform 1 more step to make your "related products" section visible. See step 3 down below:

  1. Create the 'related-products.liquid' as a section file.
  2. In the product template file, add the following section inclusion: {% section 'related-products' %} right beneath the {% section 'product-template' %} line.
  3. Exit out of HTML/CSS mode, and go to "Customize theme". Go to a product page and you'll see a newly added "Related products" section in the theme editor. Check the "Show related products" box. The related products section should appear.

@martinstephenbanks
Copy link

THANK YOU Scootcho! I was wondering what I was missing! :)

And much love Nicole Mackin, this is brilliant! Thank you so much.

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