How to exclude certain products from the Recommended Products section? (Broadcast theme)

EvaG
New Member
3 0 1

Hello! I would need no product of a certain type to appear in the recommended products section of my store.

Could you help me? I don't understand much of shopify code and haven't found the answer in the forum.

The type of product I want to hide is "Envase"

This is the code that appears in products-recommendation.liquid

<!-- /snippets/products-recommendation.liquid -->
{%- if recommendations.performed -%}
  {%- if recommendations.products_count > 0 -%}
    <div class="product-grid-outer">
      <div class="product-grid{% unless settings.product_grid_outline %} product-grid--borderless{% endunless %} flickity-button-circle product-grid--mobile-slider" id="product-recommendations" data-slider data-watch-css="true" data-cell-align="left" data-adaptive-height="false" data-dots="hidden" data-arrows="true" data-arrow-position-middle data-equalize-height="true">
        {%- assign grid_strings = 'large-up--one-quarter medium--one-quarter small--one-whole' -%}
  
        {%- for product in recommendations.products -%}
          {% assign animation_delay = forloop.index0 | times: 1 %}
          {%- assign layout_slide_attributes = 'data-slide="' | append: forloop.index0 | append: '" data-slide-index="' | append: forloop.index0 | append: '"' -%}
          {% render 'product-grid-item', product: product, grid_strings: grid_strings, animation_delay: animation_delay, additional_attributes: layout_slide_attributes, animation_anchor: '#product-recommendations' %}
        {%- endfor -%}
      </div>
    </div>
  {%- endif -%}
{%- else -%}
  <div class="related__placeholder"></div>
{%- endif -%}

 

And this is the code that appears in related.liquid

 

<!-- /sections/related.liquid -->
{%- assign has_related_products = section.settings.related_products_enable -%}
{%- assign has_recently_products = section.settings.show_recently_viewed -%}

{%- if has_related_products and product.collections.size < 1 -%}
  {% assign has_related_products = false %}
{%- endif -%}

<div class="related__wrapper js" data-section-id="{{ section.id }}" data-section-type="related">

  {%- if has_related_products and has_recently_products != true -%}
    <div class="tabs-wrapper related__products" data-tabs-holder>
      <div class="tabs__head">
        <ul class="tabs tabs--center" data-scrollbar data-scrollbar-slider>
          <li class="tab-link tab-link-0 current" data-tab="0" tabindex="0">
            {%- if section.settings.product_recommendations_heading != blank -%}
              <h2 class="recent__title">
                {{- section.settings.product_recommendations_heading -}}
              </h2>
            {%- endif -%}
          </li>
  
          <li class="tab-link tab-link-1 tab-link__recent hide" data-tab="1" tabindex="0"></li>
        </ul>

        <button type="button" class="tabs__arrow tabs__arrow--prev is-hidden is-not-relative" data-scrollbar-arrow-prev>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
  
        <button type="button" class="tabs__arrow tabs__arrow--next is-hidden is-not-relative" data-scrollbar-arrow-next>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
      </div>

      <div class="tab-content tab-content-0 current tabs__recommendation" data-tab-index="0">
        <div data-related-section data-limit="{{ section.settings.limit }}" data-product-id="{{ product.id }}">
          {%- render 'products-recommendation', product: product -%}
        </div>
      </div>

      <div class="tab-content tab-content-1 tabs__recently-viewed hide" data-tab-index="1"></div>
    </div>

  {%- elsif has_recently_products and has_related_products != true -%}
    <div class="tabs-wrapper related__products" data-tabs-holder>
      <div class="tabs__head">
        <ul class="tabs tabs--center" data-scrollbar data-scrollbar-slider>
          <li class="tab-link tab-link-0 hide" data-tab="0" tabindex="0"></li>
  
          <li class="tab-link tab-link-1 tab-link__recent current hide" data-tab="1" tabindex="0">
            {%- if section.settings.product_recently_heading != blank -%}
              <h2 class="recent__title">
                {{- section.settings.product_recently_heading -}}
              </h2>
            {%- endif -%}
          </li>
        </ul>

        <button type="button" class="tabs__arrow tabs__arrow--prev is-hidden is-not-relative" data-scrollbar-arrow-prev>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
  
        <button type="button" class="tabs__arrow tabs__arrow--next is-hidden is-not-relative" data-scrollbar-arrow-next>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
      </div>

      <div class="tab-content tab-content-0 tabs__recommendation hide" data-tab-index="0"></div>

      <div class="tab-content tab-content-1 tabs__recently-viewed current" data-tab-index="1">
        {%- render 'products-recently-viewed', product: product, product_recently_limit: section.settings.product_recently_limit -%}
      </div>
    </div>

  {%- elsif has_related_products and has_recently_products -%}
    <div class="tabs-wrapper related__products" data-tabs-holder>
      <div class="tabs__head">
        <ul class="tabs tabs--center" data-scrollbar data-scrollbar-slider>
          <li class="tab-link tab-link-0 current" data-tab="0" tabindex="0">
            {%- if section.settings.product_recommendations_heading != blank -%}
              <h2 class="recent__title">
                {{- section.settings.product_recommendations_heading -}}
              </h2>
            {%- endif -%}
          </li>
  
          {%- if section.settings.show_recently_viewed -%}
            <li class="tab-link tab-link-1 tab-link__recent hide" data-tab="1" tabindex="0">
              {%- if section.settings.product_recently_heading != blank -%}
                <h2 class="recent__title">
                  {{- section.settings.product_recently_heading -}}
                </h2>
              {%- endif -%}
            </li>
          {%- endif -%}
        </ul>

        <button type="button" class="tabs__arrow tabs__arrow--prev is-hidden is-not-relative" data-scrollbar-arrow-prev>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
  
        <button type="button" class="tabs__arrow tabs__arrow--next is-hidden is-not-relative" data-scrollbar-arrow-next>
          <span class="visually-hidden">{{ 'products.general.see_all' | t }}</span>
        </button>
      </div>

      <div class="tab-content tab-content-0 current tabs__recommendation" data-tab-index="0">
        <div data-related-section data-limit="{{ section.settings.limit }}" data-product-id="{{ product.id }}">
          {%- render 'products-recommendation', product: product, limit: section.settings.limit -%}
        </div>
      </div>

      <div class="tab-content tab-content-1 tabs__recently-viewed" data-tab-index="1">
        {%- render 'products-recently-viewed', product: product, limit: section.settings.product_recently_limit -%}
      </div>
    </div>
  {%- endif -%}
</div>

 

 

¡thanks!

Reply 1 (1)