Help with Product Recommendations Liquid Code required: You May Also Like for the Warehouse theme

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! :slightly_smiling_face:

https://www.arnoldclarkautoparts.com/collections/bikes/products/tiger-wheelie-kids-12-wheel-balance-training-bike-bicycle-v-brake

WRONG DISPLAY - as the You may also like shows unrelated products :disappointed_face:

https://www.arnoldclarkautoparts.com/products/tiger-wheelie-kids-12-wheel-balance-training-bike-bicycle-v-brake

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 -%}

{%- if section.settings.heading != blank -%}

{{ section.settings.heading | escape }}

{%- endif -%}
{%- if recommendations.performed or product.metafields.sf_related_products.enabled == 1 -%}
{%- comment -%} If the merchant is explicitly using SuperFields, we use the hand-picked related products, otherwise we switch to the Shopify automatic recommendation {%- endcomment -%}

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

#shopify-section-{{ section.id }} { display: none; }

{%- endfor -%}
{%- endif -%}

{%- endif -%}

{%- comment -%}

QUICK VIEW CONTAINER

{%- endcomment -%}

{%- render 'icon', icon: 'close' -%}
{%- render 'icon', icon: 'search-loader' -%}
{%- endif -%}

{% 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