Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
There are specific products I'm listing on another collections page private to a certain group of people. I don't want these products shown in the recommendations on the regular shop page.
Hi @selinadg,
You can add tag to these products, ex: grouppeople.
Then when displaying the product you just check the tag and don't show it:
{% for tag in product.tags %}
{% if tag contains 'grouppeople' %}
hide
{% break %}
{% endif %}
{% endfor %}
Hi @selinadg,
You add that code where recommendations on the shop page are displayed. Because I don't know the details of the recommendations file, so I can't explain it to you in detail.
Hope it helps!
@LitExtension I found the product-recommendations.liquid but not sure where to insert this code.
@selinadg
Please share your product recommendations code.
Kind regards,
Diego
Hi @selinadg,
First you need to add grouppeople tag for the products you don't want to show.
Next you will need to change the code to check it: https://i.imgur.com/zR5Z9hQ.png
{%- for product in recommendations.products -%}
<li class="grid__item small--one-half medium-up--one-quarter">
{% assign check = 0 %}
{% for tag in product.tags %}
{% if tag contains 'grouppeople' %}
{% assign check = 1 %}
{% break %}
{% endif %}
{% endfor %}
{% if check == 0 %}
{% include 'product-card-grid', max_height: 250, product: product, show_vendor: section.settings.show_vendor %}
{% endif %}
</li>
{%- endfor -%}
Hope it clear to you.
Let me know if anyone still got this problem, I can help
I am having this issue now -- I want to hide the "Green Package Protection" product from my product recommendations: https://edgelifestyle.com/collections/joggers/products/performance-joggers-black
I have tagged the product as "hidden"
and I have attached my product-recommendations.liquid
Hey, I am still having this issue and was hoping you could help me out. I basically want to remove all the products that are tagged 'Wholesale' from the product recommendation section.
The code is 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 -%}
<div class="color-{{ section.settings.color_scheme }} gradient no-js-hidden">
<product-recommendations
class="related-products page-width section-{{ section.id }}-padding isolate"
data-url="{{ routes.product_recommendations_url }}?section_id={{ section.id }}&product_id={{ product.id }}&limit={{ section.settings.products_to_show }}"
>
{% if recommendations.performed and recommendations.products_count > 0 %}
<h2 class="related-products__heading {{ section.settings.heading_size }}">
{{ section.settings.heading }}
</h2>
<ul
class="grid product-grid grid--{{ section.settings.columns_desktop }}-col-desktop grid--{{ section.settings.columns_mobile }}-col-tablet-down"
role="list"
>
{% for recommendation in recommendations.products %}
<li class="grid__item">
{% 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
%}
</li>
{% endfor %}
</ul>
{% endif %}
</product-recommendations>
</div>
{% 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 %}
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025