Below is the code I need help with. In the list of recommended products, there are some options mistakenly showing up as individual products. I want to hide these options so they do not appear as separate products in the recommended section. For better understanding, here’s a screenshot of the issue: screenshot of issue. Can anyone guide me on how to resolve this problem? Your help would be greatly appreciated.
{%- liquid
assign products_to_display = recommendations.products_count
if recommendations.products_count > section.settings.products_to_show
assign products_to_display = section.settings.products_to_show
endif
assign show_desktop_slider = false
if section.settings.show__slider and products_to_display > section.settings.columns_desktop
assign show_desktop_slider = true
endif
-%}
<div class="color-{{ section.settings.color_scheme }} gradient no-js-hidden slider-arrow--{{ section.settings.arrow_position }}">
<product-recommendations
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 %}
<div class="related-products page-width section-{{ section.id }}-padding isolate {% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
{% if recommendations.performed and recommendations.products_count > 0 %}
<slider-component>
<div class="{{ section.settings.head_align }} title-wrapper-with-link title-wrapper color-{{ section.settings.heading_color_scheme }} gradient content-container">
<div class="heading inline-richtext {% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
{%- if section.settings.title != blank -%}
<h2 class="{{ section.settings.heading_size }}">{{ section.settings.title }}</h2>
{%- endif -%}
{%- if section.settings.description -%}
<div class="{{ section.settings.description_style }} rte">
{{ section.settings.description -}}
</div>
{%- endif -%}
</div>
{%- if section.settings.show__slider and section.settings.arrow_position == 'top' -%}
<div class="wb_button_combo bcombo_auto">
<div class="wb_home_sbtn slider-buttons no-js-hidden {% unless show_desktop_slider %} desktop-arrows-hide mobile-arrows-hide {% endunless %}">
<button
type="button"
class="slider-button slider-button--prev button"
name="previous"
aria-label="{{ 'general.slider.previous_slide' | t }}"
id="slider-button--prev-{{ section.id }}"
aria-controls="slider-button--prev-{{ section.id }}">
<span>{% render 'icon-caret' %}</span>
</button>
<button
type="button"
class="slider-button slider-button--next button"
name="next"
aria-label="{{ 'general.slider.next_slide' | t }}"
id="slider-button--next-{{ section.id }}"
aria-controls="slider-button--next-{{ section.id }}">
<span>{% render 'icon-caret' %}</span>
</button>
</div>
</div>
{%- endif -%}
</div>
<div class="{% if section.settings.arrow_position == 'inline' %} relative {% endif %}">
{%- if section.settings.show__slider and section.settings.arrow_position == 'inline' -%}
<div class="wb_home_sbtn slider-buttons no-js-hidden {% unless show_desktop_slider %} desktop-arrows-hide mobile-arrows-hide {% endunless %}">
<button
type="button"
class="slider-button slider-button--prev button"
name="previous"
aria-label="{{ 'general.slider.previous_slide' | t }}"
id="slider-button--prev-{{ section.id }}"
aria-controls="slider-button--prev-{{ section.id }}">
<span>{% render 'icon-caret' %}</span>
</button>
</div>
{%- endif -%}
<ul id="Slider-{{ section.id }}-{{ block.id }}"
class="over_scroll {% if section.settings.show__slider %} slider slider--desktop slider--tablet{% endif %} grid product-grid grid--{{ section.settings.columns_desktop }}-col-desktop grid--3-col-tablet grid--{{ section.settings.columns_mobile }}-col-tablet-down"
>
{% for recommendation in recommendations.products %}
<li class="grid__item {% if section.settings.show__slider %} slider__slide{% endif %}" id="Slide-{{ section.id }}-{{ forloop.index }}">
{% render 'card-product',
card_product: recommendation,
card_style: section.settings.card_style,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_colorswatch: section.settings.show_colorswatch,
show_rating: section.settings.show_rating,
show_quick_add: section.settings.enable_quick_add,
show_variants: section.settings.show_variants,
picker_type: section.settings.picker_type,
cardstock_bar: section.settings.cardstock_bar,
show_count_timer: section.settings.show_count_timer,
max_stock: section.settings.max_stock,
limited_stock_cut_off: section.settings.limited_stock_cut_off,
limited_stock_message: section.settings.limited_stock_message,
instock_message: section.settings.instock_message,
continue_selling_message: section.settings.continue_selling_message,
limited_stock_color: section.settings.limited_stock_color,
in_stock_color: section.settings.in_stock_color,
continue_selling_color: section.settings.continue_selling_color,
quicklook_style: section.settings.quicklook_style,
color_swatchhover: section.settings.color_swatchhover,
enable_addtocart: section.settings.enable_addtocart,
stock_inventory: section.settings.stock_inventory,
section_id: section.id
%}
</li>
{% endfor %}
</ul>
{%- if section.settings.show__slider and section.settings.arrow_position == 'inline' -%}
<div class="wb_home_sbtn slider-buttons no-js-hidden {% unless show_desktop_slider %} desktop-arrows-hide mobile-arrows-hide {% endunless %}">
<button
type="button"
class="slider-button slider-button--next button"
name="next"
aria-label="{{ 'general.slider.next_slide' | t }}"
id="slider-button--next-{{ section.id }}"
aria-controls="slider-button--next-{{ section.id }}">
<span>{% render 'icon-caret' %}</span>
</button>
</div>
{%- endif -%}
</div>
</slider-component>
{% endif %}
</div>
{% endif %}
</product-recommendations>
</div>
{% javascript %}
class ProductRecommendations extends HTMLElement {
constructor() {
super();
const handleIntersection = (entries, observer) => {
if (!entries[0].isIntersecting) return;
observer.unobserve(this);
fetch(this.dataset.url)
.then(response => response.text())
.then(text => {
const html = document.createElement('div');
html.innerHTML = text;
const recommendations = html.querySelector('product-recommendations');
if (recommendations && recommendations.innerHTML.trim().length)
this.innerHTML = recommendations.innerHTML;
}
})
.catch(e => {
console.error(e);
});
}
new IntersectionObserver(handleIntersection.bind(this), {rootMargin: '0px 0px 200px 0px'}).observe(this);
}
}
customElements.define('product-recommendations', ProductRecommendations);
{% endjavascript %}
Please help as soon as possible i need urgent help. Thanks!


