Re: Product Recommendations not showing on every product page 🤔

Product Recommendations not showing on every product page 🤔

colderoshay
Tourist
3 0 1

Hey everyone!

I'm having some trouble debugging what I believe to be an issue... 

I have 'Product recommendations' turned on for my product page but for some reason it is not appearing on every page or by every path. 

 

Ex. If I visit one of my products from my homepage, the recommendations appear. However, visiting a product page through a collection or even through one of the recommendation links and the 'product recommendations' is not visible... 

Anyone have any ideas? Here's my store for context https://beauzar.com/collections/frontpage/products/bertrand vs https://beauzar.com/products/bertrand

 

Might it have something to do with the different paths?

 

Appreciate any help!

Bertrand02_–_Beauzar.pngBertrand_–_Beauzar.png

 

Replies 7 (7)

JavierSanz
Shopify Partner
36 5 7

👋 @colderoshay 

 

That seems to be rendered correctly in both URLs from my end https://share.getcloudapp.com/YEuAk27J

 

Can you send a full screenshot where we can see the exact URL where those are not rendered?

colderoshay
Tourist
3 0 1

hey @JavierSanz, You're seeing exactly what i documented in my screenshots. The variant images are showing for the product on both product pages but not the product recommendations section ("You may also like"). 

 

Hope that makes sens.

 

Thanks

pioneer100
Shopify Partner
1119 145 482
@colderoshay wrote:

hey @JavierSanz, You're seeing exactly what i documented in my screenshots. The variant images are showing for the product on both product pages but not the product recommendations section ("You may also like"). 

 

Hope that makes sens.

 

Thanks


@colderoshay  i have solution for you. put below code for related products.

{% comment %}
  Number of related items per row,
  and number of rows.
{% endcomment %}

{% assign number_of_related_products_per_row = 4 %}
{% assign number_of_rows = 1 %}

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

{% assign heading = 'Other fine products' %}

{% 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-item' %}
             {% 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 %}

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

  {% endunless %}
     
{% endif %}

reference:  https://gist.github.com/carolineschnapp/1002801#file-related-products-liquid-L32

-if you having trouble in using this code, contact me: [email protected]

- if satisfied with answer give likes and mark my answer as accepted solution

 

Thank You

If helpful, Please Like and accept The Solution.

pioneer100
Shopify Partner
1119 145 482
This issue happens becoz of shopify's url based collection.
-If you go to product page via collection page, then the url has product's collection handle, therefore it can show related product from same collection.
- and if you go directly to the product page from homepage then product page url does not have product's collection handle. So it can not show related products.

In your store, it requires to change the code for related products.

- if satisfied with answer give like.
Thank you
If helpful, Please Like and accept The Solution.
colderoshay
Tourist
3 0 1

Hey @pioneer100 Thanks for your response. 

 

Ya I see that. Is there anyway for me to change it from taking the products from a given url (ie. based on a collection) and just pulling from "all products"? 

 

My goal is to have the recommendations appear on every product page, regardless of how the user arrived there. ie From the home page, the shop page, via a recommendation link on a separate product page...

 

Let me know!

avaskye
Excursionist
36 0 7

Hi @colderoshay ! Were you able to find a solution for this by any chance? Still searching for one on my end! 

CWSites
Shopify Partner
18 0 0

This isn't 100% the case. I have a preview theme that I'm working on currently and the existing (older version of the same theme) where the older theme works and the newer one doesn't. I haven't adjusted the code in this portion at all and I navigate to the product the same way.

There has to be something else causing this issue (in my circumstance).