{%- doc -%} Renders the facet filtering component @param {object} results - The search results object @param {number} results_size - The number of products in the search results @param {object} [filters] - The filters object {%- enddoc -%} {% render 'theme-drawer-styles' %} {% render 'swatch-styles' %} {% render 'pills-styles' %} {%- liquid assign block_settings = block.settings assign products_count = results_size assign sort_by = results.sort_by | default: results.default_sort_by assign filters = filters | default: results.filters assign total_active_values = 0 # Calculate facets margin style capture facets_margin_style echo '--facets-margin: 0px ' if block_settings.filter_style == 'vertical' echo block_settings.facets_margin_right | append: 'px' | append: ' 0px' else echo ' 0px ' | append: block_settings.facets_margin_bottom | append: 'px' endif echo ' 0px;' endcapture for filter in filters case filter.type when 'price_range' if filter.min_value.value != null or filter.max_value.value != null assign total_active_values = total_active_values | plus: 1 endif when 'boolean' if filter.active_values[0].value assign total_active_values = total_active_values | plus: 1 endif else assign active_value_count = filter.active_values | size assign total_active_values = total_active_values | plus: active_value_count endcase endfor if results.url assign results_url = results.url else assign terms = results.terms | escape assign results_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by endif assign is_active = false assign should_show_pane = true if block_settings.filter_style == 'vertical' assign should_show_pane = block_settings.enable_filtering endif assign should_use_select_on_mobile = true if block_settings.enable_filtering == false and block_settings.enable_sorting assign should_use_select_on_mobile = false endif # Use collection.id if available (normal collection). Don't fall back to handle — non-numeric IDs fail GID validation. assign collection_id = results.id | default: collection.id -%} {%- liquid assign collection_id_attribute = 'data-collection-id="' | append: collection_id | append: '"' assign results_count_attribute = 'data-results-count="' | append: products_count | append: '"' # Determine page type for event dispatching if results.terms != blank assign page_type = 'search' else assign page_type = 'collection' endif assign page_type_attribute = 'data-page-type="' | append: page_type | append: '"' assign collection_handle_attribute = 'data-collection-handle="' | append: collection.handle | append: '"' assign has_custom_color = false if block_settings.background_color != blank or block_settings.text_color != blank assign has_custom_color = true endif -%} {% render 'contrast-override', background_color: block_settings.background_color, text_color: block_settings.text_color, section_id: block.id %} {% if block_settings.enable_filtering or block_settings.enable_sorting or block_settings.enable_grid_density %} {% if block_settings.filter_style == 'vertical' %} {% # These elements are always rendered in the horizontal bar that's why we apply the .facets--horizontal class %}