Collection Page Filters

We have filters set up on the left hand side.

I would like the filter “lift type” to NOT appear on the collection handle “treatment-couch-upholstery”

When I try an “unless” clause, it removes all filters from all collections


{% if collection.handle == 'treatment-couches' 
or collection.handle == 'hydraulic-couches' 
or collection.handle == 'examination-couches' 
or collection.handle == 'electric-couches' 
or collection.handle =='blue-treatment-couches'
or collection.handle =='black-treatment-couches'
or collection.handle =='white-treatment-couches'
or collection.handle =='1-section-massage-beds'
or collection.handle =='2-section-treatment-couches'
or collection.handle =='3-section-treatment-couches'
or collection.handle =='5-section-massage-beds'
or collection.handle =='beauty-couches'
or collection.handle =='massage-beds'
or collection.handle =='neurology-couches'
or collection.handle =='physiotherapy-beds'
or collection.handle =='podiatry-couches'
or collection.handle =='tatoo-couches'
or collection.handle =='addax-treatment-couches'
or collection.handle =='plinth-medical-treatment-couches'
or collection.handle =='avalon-treatment-couches'
or collection.handle == 'treatment-couch-upholstery'
%}
  {% comment %} custom-filters.liquid {% endcomment %}
  
{% assign color_whitelist = ' Blue,Black,Pink,Graphite,White,Light,Cocoa,White Orchid,Magnum, Gunmetal Grey,Grey,Purple Iris,Mink,Lupin Blue,Hunter Green,Cobalt, Chablis,Burgundy,Blue Jay,Wasabi,Sea Green,Sapphire,Rainforest, Pink/Grey,Pink with Bag,Pillarbox,Mulled Wine,Marigold,Lupin,Jasmine, Grape,Gingersnap,Denim,Cool Blue,Citrus Green,Candy,Biscuit,Battleship, Atlantic,Almond,Yellow,Tomato,Spectra Royal,Sky Blue,Sapphire Blue,Sand, Red,Purple,Navy,Mid Blue,Matte Black,Koala,Individual,Fuscia,Dune, Damson,Cream,Blush,Beige,Ash Grey,Applemint ' | split: ',' %} {% assign all_colors = '' %} {%- for product in collection.products -%} {% assign found_colors = '' %} {% assign product_title = product.title | downcase %} {%- for color in color_whitelist -%} {% assign color_trim = color | strip %} {% assign color_downcase = color_trim | downcase %} {% if product_title contains color_downcase %} {% unless found_colors contains color_trim %} {% assign all_colors = all_colors | append: color_trim | append: ',' %} {% assign found_colors = found_colors | append: color_trim | append: ',' %} {% endunless %} {% endif %} {%- endfor -%} {% for variant in product.variants %} {% if variant.options[0] and variant.options[0] != 'Default Title' %} {% assign variant_color = variant.options[0] | strip %} {% assign variant_color_downcase = variant_color | downcase %} {% for color in color_whitelist %} {% assign color_trim = color | strip %} {% assign color_downcase = color_trim | downcase %} {% if variant_color_downcase == color_downcase %} {% unless found_colors contains color_trim %} {% assign all_colors = all_colors | append: color_trim | append: ',' %} {% assign found_colors = found_colors | append: color_trim | append: ',' %} {% endunless %} {% endif %} {% endfor %} {% endif %} {% endfor %} {% endfor %} {% assign all_colors_array = all_colors | split: ',' %} {% assign unique_colors = all_colors_array | uniq %} {%- assign color_count_array = '' -%} {% for color in unique_colors %} {% assign color_count = 0 %} {% assign color_lower = color | downcase %} {% for product in collection.products %} {% assign matched = false %} {% assign product_title = product.title | downcase %} {% if product_title contains color_lower %} {% assign matched = true %} {% endif %} {% unless matched %} {% for variant in product.variants %} {% if variant.options[0] and variant.options[0] != 'Default Title' %} {% assign variant_color = variant.options[0] | downcase %} {% if variant_color == color_lower %} {% assign matched = true %} {% endif %} {% endif %} {% endfor %} {% endunless %} {% if matched %} {% assign color_count = color_count | plus: 1 %} {% endif %} {% endfor %} {% if color != '' %} {% assign padded_count = color_count | prepend: '0000' | slice: -4, 4 %} {% assign color_count_array = color_count_array | append: padded_count | append: '_' | append: color | append: '|' %} {% endif %} {% endfor %} {% assign color_count_pairs = color_count_array | split: '|' | sort | reverse %}

COLOUR

{% assign filter_index = 0 %} {% for entry in color_count_pairs %} {% if entry contains '_' %} {% assign parts = entry | split: '_' %} {% assign count = parts[0] | plus: 0 %} {% assign color = parts[1] %} {% if color != '' %} {% if count == 0 %} {% assign is_disabled = true %} {% else %} {% assign is_disabled = false %} {% endif %} {{ color }} ({{ count }}) {% endif %} {% endif %} {% endfor %} Show more
{% comment %} Section Filters {% endcomment %}

Number of Sections

{% assign section_whitelist = '2 Sections,3 Sections,5 Sections' | split: ',' %} {% assign all_sections = '' %} {%- for product in collection.products -%} {% assign product_title = product.title | downcase %} {%- for section in section_whitelist -%} {% assign section_trim = section | strip %} {% assign section_downcase = section_trim | downcase %} {% assign singular_downcase = section_downcase | replace: 'sections', 'section' %} {% assign word_downcase = section_downcase | replace: '2 sections', 'two sections' | replace: '3 sections', 'three sections' | replace: '5 sections', 'five sections' %} {% if product_title contains section_downcase or product_title contains singular_downcase or product_title contains word_downcase %} {% unless all_sections contains section_trim %} {% assign all_sections = all_sections | append: section_trim | append: ',' %} {% endunless %} {% endif %} {%- endfor -%} {% endfor %} {% assign all_sections_array = all_sections | split: ',' %} {% assign unique_sections = all_sections_array | uniq %} {%- assign section_count_array = '' -%} {% for section in unique_sections %} {% assign section_count = 0 %} {% assign section_lower = section | downcase %} {% assign singular_lower = section_lower | replace: 'sections', 'section' %} {% assign word_lower = section_lower | replace: '2 sections', 'two sections' | replace: '3 sections', 'three sections' | replace: '5 sections', 'five sections' %} {% for product in collection.products %} {% assign product_sections = product.metafields.custom.section_count | default: product.title | downcase %} {% if product_sections contains section_lower or product_sections contains singular_lower or product_sections contains word_lower %} {% assign section_count = section_count | plus: 1 %} {% endif %} {% endfor %} {% if section != '' %} {% assign padded_count = section_count | prepend: '0000' | slice: -4, 4 %} {% assign section_count_array = section_count_array | append: padded_count | append: '_' | append: section | append: '|' %} {% endif %} {% endfor %} {% assign section_count_pairs = section_count_array | split: '|' | sort | reverse %} {% for entry in section_count_pairs %} {% if entry contains '_' %} {% assign parts = entry | split: '_' %} {% assign count = parts[0] | plus: 0 %} {% assign section = parts[1] | downcase %} {% if section != '' %} {% if count == 0 %} {% assign is_disabled = true %} {% else %} {% assign is_disabled = false %} {% endif %} {{ section }} ({{ count }}) {% endif %} {% endif %} {% endfor %} {% if section_count_pairs.size == 0 %}

No section filters available.

{% endif %}
{% comment %} Section Filters {% endcomment %}

Lift Type

{% assign power_whitelist = 'Hydraulic,Electric' | split: ',' %} {% assign all_powers = '' %} {%- for product in collection.products -%} {% assign product_title = product.title | downcase %} {%- for power in power_whitelist -%} {% assign power_downcase = power | downcase %} {% if product_title contains power_downcase %} {% unless all_powers contains power %} {% assign all_powers = all_powers | append: power | append: ',' %} {% endunless %} {% endif %} {%- endfor -%} {% endfor %} {% assign all_powers_array = all_powers | split: ',' %} {% assign unique_powers = all_powers_array | uniq %} {%- assign power_count_array = '' -%} {% for power in unique_powers %} {% assign power_count = 0 %} {% assign power_lower = power | downcase %} {% for product in collection.products %} {% assign title = product.title | downcase %} {% if title contains power_lower %} {% assign power_count = power_count | plus: 1 %} {% endif %} {% endfor %} {% if power != '' %} {% assign padded_count = power_count | prepend: '0000' | slice: -4, 4 %} {% assign power_count_array = power_count_array | append: padded_count | append: '_' | append: power | append: '|' %} {% endif %} {% endfor %} {% assign power_count_pairs = power_count_array | split: '|' | sort | reverse %} {% for entry in power_count_pairs %} {% if entry contains '_' %} {% assign parts = entry | split: '_' %} {% assign count = parts[0] | plus: 0 %} {% assign power = parts[1] %} {% if power != '' %} {% if count == 0 %} {% assign is_disabled = true %} {% else %} {% assign is_disabled = false %} {% endif %} {{ power }} ({{ count }}) {% endif %} {% endif %} {% endfor %} {% if power_count_pairs.size == 0 %}

No power filters available.

{% endif %}
Clear All {% comment %}
Showing {{ collection.products.size }} products
{% endcomment %}
.custom-filters { padding: 0px; } .filter-option { display: block; width: 100%; margin: 5px 0; font-family: Montserrat, sans-serif; font-weight: 500; font-style: normal; line-height: 1.6; cursor: pointer; } .filter-option.disabled { opacity: 0.5; pointer-events: none; } .filter-option.disabled input { cursor: not-allowed; } .filter-checkbox { margin-right: 5px; } .load-more-btn { color: #416eb5; text-underline-offset: 0.2em; text-decoration: underline 1px; cursor: pointer; border: none; background-color: white; padding: 0px; } .clear-filters-btn { margin-top: 10px; background-color: white; border: 1px solid #000; cursor: pointer; text-transform: uppercase; height: 36px; text-align: center; letter-spacing: 0.05rem; padding: 0 25px; width: 100%; } /* .clear-filters-btn:hover { background-color: #e0e0e0; } */ .filters-grid { transition: opacity 0.3s ease; } .filters-grid.hidden { display: none; } .filter-count { margin-top: 10px; font-size: 14px; color: #555; } .filter-content { max-height: 0; overflow: hidden; opacity: 0; transition: max-height 0.3s ease, opacity 0.3s ease; } .filter-content.open { max-height: 100%; /* adjust based on expected max height */ opacity: 1; } .accordion-toggle { cursor: pointer; font-weight: bold; margin-bottom: 15px; display: flex; justify-content: space-between; align-items: center; } .filter-group { margin-bottom: 15px; } .icon-wrapper { display: flex; align-items: center; } .icon-open { display: none; transition: opacity 0.3s ease; } .accordion-toggle.open .icon-closed { display: none; transition: opacity 0.3s ease; } .accordion-toggle.open .icon-open { display: inline; transition: opacity 0.3s ease; } /* Custom Drawer for mobile -- filters */

{% endif %}

Hello @ChrisW3

simply wrap that entire < details > < /details > block with the condition.

Add this line directly ABOVE the < details is=“filter-details” > tag for the “Lift Type” filter:

{% unless collection.handle == 'treatment-couch-upholstery' %}

Add this line directly AFTER the closing tag for that same section:

{% endunless %}

After making this change and saving the file, the “Lift Type” filter will no longer appear on the “treatment-couch-upholstery” collection page.

Thank You!

The filter should not appear by default if collection product has no product having this property.

Technically, you can have something like

{% if collection.handle == 'treatment-couch-upholstery' %}
  <style> 
    .filter-group:has(#power-filter-container) {
      display: none;
    }
  </style>
{% endif %}

Thanks Tim, this worked perfectly!