Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am looking to hide a selection of products from my product-recommendation section. I tagged all these products with _hidden so they are automatically added to a collection called "Hidden". I want to hide this collection from my recommendations section.
Here is the code for product-recommendations.liquid not including the schema. i know i need an if statement but don't know where to put it.
{%- assign use_recommendations = true -%}
{%- assign hand_picked_count = 0 -%}
{%- for block in section.blocks -%}
{%- if block.settings.product != blank -%}
{%- assign use_recommendations = false -%}
{%- assign hand_picked_count = hand_picked_count | plus: 1 -%}
{%- endif -%}
{%- endfor -%}
{%- capture section_settings -%}
{
"productId": {{ product.id | json }},
"useRecommendations": {{ use_recommendations | json }},
"recommendationsCount": 4
}
{%- endcapture -%}
{%- capture flickity_options -%}
{
"prevNextButtons": true,
"pageDots": false,
"wrapAround": false,
"contain": true,
"cellAlign": "center",
"watchCSS": true,
"dragThreshold": 8,
"groupCells": true,
"arrowShape": {"x0": 20, "x1": 60, "y1": 40, "x2": 60, "y2": 35, "x3": 25}
}
{%- endcapture -%}
<section class="Section Section--spacingNormal" data-section-id="{{ section.id }}" data-section-type="product-recommendations" data-section-settings='{{ section_settings }}'>
{%- if section.settings.heading != blank -%}
<header class="SectionHeader SectionHeader--center">
<div class="Container">
<h3 class="SectionHeader__Heading Heading u-h3">{{ section.settings.heading | escape }}</h3>
</div>
</header>
{%- endif -%}
<div class="ProductRecommendations">
{%- if hand_picked_count > 0 or recommendations.performed and recommendations.products.size > 0 -%}
<div class="ProductListWrapper">
<div class="ProductList ProductList--carousel Carousel" data-flickity-config='{{ flickity_options }}'>
{%- if hand_picked_count > 0 -%}
{%- for block in section.blocks -%}
{%- assign product = block.settings.product -%}
{%- if product != blank -%}
<div class="Carousel__Cell">
{% render 'product-item', product: product, show_product_info: section.settings.show_product_info, show_vendor: section.settings.show_vendor, show_color_swatch: section.settings.show_color_swatch, show_labels: true %}
</div>
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for product in recommendations.products -%}
<div class="Carousel__Cell">
{% render 'product-item', product: product, show_product_info: section.settings.show_product_info, show_vendor: section.settings.show_vendor, show_color_swatch: section.settings.show_color_swatch, show_labels: true %}
</div>
{%- endfor -%}
{%- endif -%}
</div>
</div>
{%- else -%}
{%- comment -%}Hide the section if there is no recommendations to show{%- endcomment -%}
<style>
#shopify-section-{{ section.id }} {
display: none;
}
</style>
{%- endif -%}
</div>
</section>
Solved! Go to the solution
This is an accepted solution.
I solved myself.
can you tell me how you solved this? I need to do the same thing
Fake news. The solution I used didn't work, BUT I stopped using the recommendation engine that is built in and started using a different app for it. it was not cheap. the solution I used before this was just setting whatever products I want as the featured products.
I found this solution on a different thread, tested it and it works for me: https://community.shopify.com/c/technical-q-a/is-there-a-way-to-hide-specific-products-from-the-prod...
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025