New Shopify Certification now available: Liquid Storefronts for Theme Developers

Filter problem / Documentation problem

10 1 2

Hello there!

I am developing a product filter according to the official documentation:
URL-address and filtering is correctly.

1. If you select multiple options in one of the filters, only the last pressed option remains checked.
2. An error occurs when displaying an object: {{ filter.active_values }}

Please help solve the problems. I would be very grateful to you.

Here is my code. I have checked it several times. It fully complies with the documentation. If you paste a snippet from the official documentation, it works the same way!



<div class="d-block row mb-5">
	<form class="col d-flex flex-wrap mb-n4">
		{%- for filter in collection.filters -%}
		<div class="dropdown me-2 mb-2">
			<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdown-menu-{{ filter.label }}-{{ forloop.index }}" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
				{{ filter.label | capitalize }}
				{%- if filter.active_values.size > 0 -%}
					<span>({{ filter.active_values.size }})</span>
				{%- endif -%}
			<ul class="dropdown-menu" aria-labelledby="dropdown-menu-{{ filter.label }}-{{ forloop.index }}">
				{%- case filter.type -%}
					{%- when 'list' -%}
						<li class="d-flex flex-nowrap justify-content-between px-3 py-1">
							<span class="text-muted">{{ filter.active_values.size }} selected</span>
							<span>{{ filter.active_values }}</span>
							{%- if filter.active_values.size > 0 -%}
								<a href="{{ filter.url_to_remove }}" class="text-decoration-none">Reset</a>
							{%- endif -%}
						<hr class="dropdown-divider"></li>
						{%- for filter_value in filter.values -%}
							<li class="ps-3 pe-4 py-1">
								<div class="form-check">
										name="{{ filter_value.param_name }}"
										value="{{ filter_value.value }}"
										id="Filter-{{ filter.label }}-{{ forloop.index }}"
										{% if -%}checked{%- endif %}
										{% if filter_value.count == 0 and == false -%}disabled{%- endif %}
									<label class="form-check-label text-nowrap" for="Filter-{{ filter.label }}-{{ forloop.index }}">
										{{ filter_value.label }}
						{%- endfor -%}
						<li class="ps-3 pe-4 py-1"><input type="submit" value="Apply" class="btn btn-primary btn-sm"></li>
					{%- when 'price_range' -%}
						{% comment %} I have temporarily removed the implementation for readability {% endcomment %}
				{%- endcase -%}
		{%- endfor -%}



Here are screenshots of the problem

Step 1 — Selecting and apply filter options on page: «/collections/all»:
Снимок экрана 2021-10-05 в 15.36.17.png

Step 2 — Filtration results. The page address is correct. The list of goods is correct. Checkboxes aren't correct.
Object {{ filter.active_values }} isn't displayed (error)

Снимок экрана 2021-10-05 в 15.37.32.png

Accepted Solution (1)
10 1 2

This is an accepted solution.

I solved the problem. The filter does not work correctly only in the local copy of the store.

View solution in original post

Replies 4 (4)
10 1 2

This is an accepted solution.

I solved the problem. The filter does not work correctly only in the local copy of the store.

23 0 8


Can you confirm what you mean by this?

Do you just mean that your filters didnt work while you were in 'preview' mode but then they started working correctly when you set the theme to 'live'?

Im having problems rewriting the filters too but Im having to recreate the filter by tag functionality so using collection.all_tags instead and wondering if it will work differently if I set the theme to 'live'.


10 1 2

In my case, after applying the filter, only the last selected value (checkbox) was transmitted to the URL. I advise you to do a git push after every filter change and test it on a live store.

Shopify Partner
3 0 2

Thanks for sharing this. It helped me work around the issue - I was only seeing the problem when using shopify theme serve but if I push my code to the published theme, the issue goes away. Frustrating!