Hide products from product recommendations (Broadcast Theme)

Hey there,

I am using the Broadcast theme and am having some trouble hiding products from the product recommendations section. I am using the Bold Product Options App to add additional product options and the way it does this is create hidden product collections with the tag ‘OPTIONS_HIDDEN_PRODUCT’. But these products are still showing up in the product recommendations section.

Thanks!

Hi @AnnaH

I hope you are doing good and welcome to the Shopify Community!
I am San from MS Web Designer.

To hide products from the product recommendations section on the Shopify Broadcast theme, you can follow these steps:

  1. Open your Shopify admin and go to “Online Store” > “Themes”.

  2. Click on “Actions” > “Edit code” for the Broadcast theme.

  3. In the left-hand sidebar, click on “Sections” > “product-recommendations.liquid”.

  4. Scroll down to the product_recommendations block. This is the code that generates the product recommendations.

  5. To exclude specific products from the recommendations, you can add a where filter to the for loop that iterates through the recommended products. For example, if you want to exclude products with the tag “exclude-recommendations”, you can modify the loop as follows:
    {% for product in product_recommendations.products %}
    {% unless product.tags contains ‘exclude-recommendations’ %}
    // code to display recommended product
    {% endunless %}
    {% endfor %}
    The unlessstatement checks if thetags property of the current product contains the “exclude-recommendations” tag. If it does, the code inside the block is not executed, and the product is excluded from the recommendations.

  6. Save the file and preview your store to see the updated product recommendations section without the excluded products.

    Note that this method only hides the excluded products from the recommendations section, but they will still be visible in their respective collections and search results.

Regards,

San

2 Likes

Hi @AnnaH
Can you kindly share your store link (with the password, if any) with us? We will check it and suggest you a solution if possible.

This is the preview link I’m working on:
https://kj2qfd8rcnaeeut3-24638905.shopifypreview.com

Sorry but your preview link is time-expired. Can you send another preview link to me?

This worked great! Thanks so much

1 Like

I am also having this issue i have tried to put in the code you suggested above and i must be doing it wrong please help.

I have listed the code below for the .liquid file

{{ ‘component-card.css’ | asset_url | stylesheet_tag }}
{{ ‘component-price.css’ | asset_url | stylesheet_tag }}
{{ ‘section-related-products.css’ | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{% if recommendations.performed and recommendations.products_count > 0 %}

{{ section.settings.heading }}

    {% for recommendation in recommendations.products %}
  • {% render 'card-product', card_product: recommendation, media_aspect_ratio: section.settings.image_ratio, show_secondary_image: section.settings.show_secondary_image, show_vendor: section.settings.show_vendor, show_rating: section.settings.show_rating %}
  • {% endfor %}
{% endif %}

{% schema %}
{
“name”: “t:sections.related-products.name”,
“tag”: “section”,
“class”: “section”,
“settings”: [
{
“type”: “paragraph”,
“content”: “t:sections.related-products.settings.paragraph__1.content”
},
{
“type”: “inline_richtext”,
“id”: “heading”,
“default”: “You may also like”,
“label”: “t:sections.related-products.settings.heading.label”
},
{
“type”: “select”,
“id”: “heading_size”,
“options”: [
{
“value”: “h2”,
“label”: “t:sections.all.heading_size.options__1.label”
},
{
“value”: “h1”,
“label”: “t:sections.all.heading_size.options__2.label”
},
{
“value”: “h0”,
“label”: “t:sections.all.heading_size.options__3.label”
}
],
“default”: “h1”,
“label”: “t:sections.all.heading_size.label”
},
{
“type”: “range”,
“id”: “products_to_show”,
“min”: 2,
“max”: 10,
“step”: 1,
“default”: 4,
“label”: “t:sections.related-products.settings.products_to_show.label”
},
{
“type”: “range”,
“id”: “columns_desktop”,
“min”: 1,
“max”: 5,
“step”: 1,
“default”: 4,
“label”: “t:sections.related-products.settings.columns_desktop.label”
},
{
“type”: “select”,
“id”: “color_scheme”,
“options”: [
{
“value”: “accent-1”,
“label”: “t:sections.all.colors.accent_1.label”
},
{
“value”: “accent-2”,
“label”: “t:sections.all.colors.accent_2.label”
},
{
“value”: “background-1”,
“label”: “t:sections.all.colors.background_1.label”
},
{
“value”: “background-2”,
“label”: “t:sections.all.colors.background_2.label”
},
{
“value”: “inverse”,
“label”: “t:sections.all.colors.inverse.label”
}
],
“default”: “background-1”,
“label”: “t:sections.all.colors.label”,
“info”: “t:sections.all.colors.has_cards_info”
},
{
“type”: “header”,
“content”: “t:sections.related-products.settings.header__2.content”
},
{
“type”: “select”,
“id”: “image_ratio”,
“options”: [
{
“value”: “adapt”,
“label”: “t:sections.related-products.settings.image_ratio.options__1.label”
},
{
“value”: “portrait”,
“label”: “t:sections.related-products.settings.image_ratio.options__2.label”
},
{
“value”: “square”,
“label”: “t:sections.related-products.settings.image_ratio.options__3.label”
}
],
“default”: “adapt”,
“label”: “t:sections.related-products.settings.image_ratio.label”
},
{
“type”: “checkbox”,
“id”: “show_secondary_image”,
“default”: false,
“label”: “t:sections.related-products.settings.show_secondary_image.label”
},
{
“type”: “checkbox”,
“id”: “show_vendor”,
“default”: false,
“label”: “t:sections.related-products.settings.show_vendor.label”
},
{
“type”: “checkbox”,
“id”: “show_rating”,
“default”: false,
“label”: “t:sections.related-products.settings.show_rating.label”,
“info”: “t:sections.related-products.settings.show_rating.info”
},
{
“type”: “header”,
“content”: “t:sections.related-products.settings.header_mobile.content”
},
{
“type”: “select”,
“id”: “columns_mobile”,
“default”: “2”,
“label”: “t:sections.related-products.settings.columns_mobile.label”,
“options”: [
{
“value”: “1”,
“label”: “t:sections.related-products.settings.columns_mobile.options__1.label”
},
{
“value”: “2”,
“label”: “t:sections.related-products.settings.columns_mobile.options__2.label”
}
]
},
{
“type”: “header”,
“content”: “t:sections.all.padding.section_padding_heading”
},
{
“type”: “range”,
“id”: “padding_top”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_top”,
“default”: 36
},
{
“type”: “range”,
“id”: “padding_bottom”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_bottom”,
“default”: 36
}
]
}
{% endschema %}

Hi! Im using the sense theme. Any advice on how I can exclude some products from my product recommendations?