Hi Everyone,
I’m looking for some advice. We are using the warehouse theme and the product recommendations You may also like have never worked properly from the beginning.
We would like to display the related products in the same way as the CORRECT example below. I’ve attached the code and hopefully, it will be simple to fix.
CORRECT DISPLAY!
WRONG DISPLAY - as the You may also like shows unrelated products
The code is for the product-recommendations.liquid
{%- capture section_settings -%}
{
“stackable”: false,
“layout”: “vertical”,
“productId”: {{ product.id | json }},
“useRecommendations”: {% if product.metafields.sf_related_products.enabled == 1 %}false{% else %}true{% endif %},
“recommendationsCount”: 10
}
{%- endcapture -%}
{%- if section.settings.show_product_recommendations -%}
{{ section.settings.heading | escape }}
{%- endif -%}{%- if product.metafields.sf_related_products.enabled == 1 -%}
{%- for i in (1..6) -%}
{%- assign related_product_option = ‘product_’ | append: i -%}
{%- assign related_product = all_products[product.metafields.sf_related_products[related_product_option]] -%}
{%- unless related_product.empty? -%}
{%- render ‘product-item’, product: related_product, grid_classes: ‘1/4–lap 1/5–desk 1/6–wide’, show_add_to_cart: section.settings.show_quick_buy -%}
{%- endunless -%}
{%- endfor -%}
{%- else -%}
{%- for product in recommendations.products -%}
{%- render ‘product-item’, product: product, grid_classes: ‘1/4–lap 1/5–desk 1/6–wide’, show_add_to_cart: section.settings.show_quick_buy -%}
{%- else -%}
{%- comment -%}Hide the section if there is no recommendations to show{%- endcomment -%}
{%- endfor -%}
{%- endif -%}
{%- comment -%}
QUICK VIEW CONTAINER
{%- endcomment -%}
{% schema %}
{
“name”: “Product recommendations”,
“settings”: [
{
“type”: “checkbox”,
“id”: “show_product_recommendations”,
“label”: “Show dynamic recommendations”,
“info”: “Dynamic recommendations change and improve with time. Learn more”,
“default”: true
},
{
“type”: “text”,
“id”: “heading”,
“label”: “Heading”,
“default”: “You may also like”
},
{
“type”: “checkbox”,
“id”: “show_quick_buy”,
“label”: “Show quick buy”,
“default”: false
}
]
}
{% endschema %}
If you can help me fix this, I’d be happy to connect up.
Thanks, Dave