{%- liquid assign recommend_products = true if recommendations.products and recommendations.products_count > 0 assign related_collection = recommendations endif for tag in product.tags if tag contains '_related' assign include_collection_handle = tag | split: '_' | last assign include_collection = collections[include_collection_handle] if include_collection != empty and include_collection.products_count > 0 assign related_collection = include_collection assign recommend_products = false break endif endif endfor assign number_of_products = section.settings.related_count -%} {%- if section.settings.show_product_recommendations -%}

{{ section.settings.product_recommendations_heading }}

{%- if recommend_products -%}
{% comment %} This content is visually hidden and replaced when recommended products show up {% endcomment %}
{%- endif -%} {%- if related_collection.products_count > 1 -%}
{%- for product in related_collection.products limit: number_of_products -%} {%- render 'product-grid-item', product: product, per_row: number_of_products, quick_shop_enable: settings.quick_shop_enable -%} {%- endfor -%}
{%- endif -%}
{%- 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](https://help.shopify.com/en/themes/development/recommended-products)", "default": true }, { "type": "text", "id": "product_recommendations_heading", "label": "Heading", "default": "You may also like" }, { "type": "range", "id": "related_count", "label": "Number of related products", "default": 5, "min": 2, "max": 6, "step": 1 } ] } {% endschema %}