how to change number of recommended products

New Member
13 0 0

On the product page, there's a 'you might also like' section. Currently there are 4 products to recommend. 

I would like to reduce that number to three. Where can I change this, and how do i change the specific recommended products?

0 Likes
Shopify Staff
Shopify Staff
109 0 16

Hey Mike! 

Where you make this change could vary depending on your theme. If your theme has this option built in, I would take a look at the product.liquid template to find the code, or snippet the related products are being controlled from. 

For example, in Shopify's Classic theme the related product's code is being included on the product pages from the related-products.liquid snippet file. 

In the related-products.liquid snippet, on the first line that can be modified to change the total amount of products being shown. 

Take a look through your theme templates to see if you can trace where the code is resting. If you cannot find it then try pasting your product.liquid code here and I may be able to spot the code or which snippet you should be looking in. 

In regards to determine which products are included in the recommendations, usually the way they work by default is to pull up other products from the same collection as the product that is currently being viewed. You can change this to be determined by other factors though (i.e. product tags) using the steps in this guide

I hope that helps!

Cheers,
Bob O. 

0 Likes
New Member
17 0 0

Hi Mike;

Hope you’re doing well. First of all, sorry for my late response!

Shopify's related products section is a handy feature - a lot of merchants are using it. 

However I believe a fully-fledged personalization app, such as Perzonalization, is indeed what you need. With the help of Perzonalization you’ll be able to;

  • Showcase popular products, Products viewed by similar shoppers or Recent products
  • Show custom recommendations where you choose which set of collections, colors etc. will be displayed
  • Display recommendation widgets on home, cart, product, search no results, collection pages
  • Place personalized recommendation on your e-mail templates

Give it a 14 day free try and let me know what you think!

Best of luck!

Ilke Karabogali

Disclaimer: I am the co-founder of Perzonalization; a predictive personalization SaaS solution which is used by eCommerce websites.

0 Likes
New Member
2 0 0

Hi Bob, 

I'm trying to limit the number of recommended products to 4, but cant find where I should make that change...can you help me? I use the boundless theme. Im sending you the code of the related-product-liquid

Thanks

 

{% if section.settings.show_related_products == true %}
<style>
  h2.section-header__title {
    text-align: center;
  }
</style>
<hr>
<div itemscope itemtype="http://schema.org/Product" id="ProductSection-{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="product" data-enable-history-state="true">
 
{% comment %}
  Number of related items per row,
  and number of rows.
{% endcomment %}

{% assign number_of_related_products_per_row = section.settings.related_grid_num %}
{% assign number_of_rows = section.settings.related_grid_row %}

{% comment %}
  Heading.
  Leave blank if you don't need one.
{% endcomment %}

{% assign heading = section.settings.related_title %}

{% comment %}
  Set either or both to true, if you want
  to limit yourself to items with same vendor, and/or type.
{% endcomment %}

{% assign same_vendor = false %}
{% assign same_type = false %}

{% comment %}
  Collections to ignore.
  Never pick related items from those.
{% endcomment %}

{% assign exclusions = 'frontpage,all' | split: ',' %}

{% comment %}
  Looking for a relevant collection.
{% endcomment %}

{% if product.metafields.c_f['Related Products'] %}
  {% assign collection = collections[product.metafields.c_f['Related Products']] %}
{% endif %}

{% assign found_a_collection = false %}
{% if collection and collection.all_products_count > 1 %}
  {% unless exclusions contains collection.handle %}
    {% assign found_a_collection = true %}
  {% endunless %}
{% endif %}
{% unless found_a_collection %}
  {% for c in product.collections %}
    {% unless exclusions contains c.handle or c.all_products_count < 2 %}
      {% assign found_a_collection = true %}
      {% assign collection = c %}
      {% break %}
    {% endunless %}
  {% endfor %}
{% endunless %}

{% comment %}
  If we have a relevant collection.
{% endcomment %}

{% if found_a_collection %}

  {% assign counter = 0 %}
  {% assign break_at = number_of_rows | times: number_of_related_products_per_row %}
  {% assign current_product = product %}

    {% case number_of_related_products_per_row %}
    {% when '1' %}
      {% assign grid_item_width = '' %}
    {% when '2' %}
      {% assign grid_item_width = 'large--one-half medium--one-half' %}
    {% when '3' %}
      {% assign grid_item_width = 'large--one-third medium--one-half' %}
    {% when '4' %}
      {% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half' %}
    {% when '5' %}
      {% assign grid_item_width = 'large--one-fifth medium--one-third small--one-half' %}
    {% when '6' %}
      {% assign grid_item_width = 'large--one-sixth medium--one-third small--one-half' %}
    {% else %}
      {% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half' %}
  {% endcase %}


  {% capture related_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-width' with product_image_type: section.settings.product_image_type, product_image_size: section.settings.product_image_size %}
    {% include 'product-grid-item' with product_image_spacing: section.settings.product_image_spacing, vendor_enable: section.settings.vendor_enable %}

             {% assign counter = counter | plus: 1 %}
             {% if counter == break_at %}
               {% break %}
             {% endif %}
           {% endunless %}
        {% endunless %}
      {% endunless %}
    {% endfor %}
  {% endcapture %}

  {% assign related_items = related_items | trim %}

  {% unless related_items == blank %}

      {% unless heading == blank %}
      <header class="section-header">
        <h2 class="section-header__title">{{ heading }}</h1>
      </header>
      {% endunless %}
      <div class="product grid grid--uniform grid--no-gutters">
        {{ related_items }}
      </div>

  {% endunless %}
     
{% endif %}
  
</div>
{% endif %}

{% schema %}
{
  "name": "Related products",
  "settings": [
    {
      "type": "checkbox",
      "id": "show_related_products",
      "label": "Show related products",
      "default": false
    },
    {
      "id": "related_title",
      "type": "text",
      "label": "Section title",
      "default": "Other fine products"
    },
    {
        "type": "select",
        "id": "product_image_type",
        "label": "Image style",
        "options": [
          {
            "value": "portrait",
            "label": "Tall/square"
          },
          {
            "value": "landscape",
            "label": "Wide"
          }
        ]
      },
      {
        "type": "select",
        "id": "product_image_size",
        "label": "Image size",
        "default": "medium",
        "options": [
          {
            "value": "small",
            "label": "Small"
          },
          {
            "value": "medium",
            "label": "Medium"
          },
          {
            "value": "large",
            "label": "Large"
          },
          {
            "value": "xlarge",
            "label": "Extra large"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "product_image_spacing",
        "label": "Add spacing between images"
      },
      {
        "type": "checkbox",
        "id": "vendor_enable",
        "label": "Show product vendor"
      }
  ]
}
{% endschema %}

0 Likes
Shopify Partner
42 2 6

Hi, In order to have 4 products showed in (related products snippet), look for this line 

{%- for product in recommendations.products -%}

and change it to :

{%- for product in recommendations.products limit: 4 -%}
The best and fastest Shopify theme www.plaktheme.com
0 Likes