liquid icon indicating copy to clipboard operation
liquid copied to clipboard

filter_value.url_to_add it's not replacing the active filter

Open lpelati opened this issue 3 years ago • 0 comments

filter_value.url_to_add it's definitely not working as I'd expect from reading the doc: https://shopify.dev/api/liquid/objects/filter-value#filter_value-url_to_add

When I use it's not returning me the current page URL with the filter value parameter added, it's instead returning me the current page url with an extra url parameter appended at the end. Which sounds similar, but it's all different story.

Let me explain better. Let's assume I have two sets of filters (color and size).

Colors: <a href="/collections/sale?filter.v.option.color=black">Black</a> <a href="/collections/sale?filter.v.option.color=red">Red</a> <a href="/collections/sale?filter.v.option.color=blue">Blue</a>

Sizing: <a href="/collections/sale?filter.v.option.size=M">M</a> <a href="/collections/sale?filter.v.option.size=L">L</a>

All good so far. Let's say that I click on color Black, this is what happens:

Colors: <a href="/collections/sale?filter.v.option.color=black">Black</a> <a href="/collections/sale?filter.v.option.color=black&filter.v.option.color=red">Red</a> <a href="/collections/sale?filter.v.option.color=black&filter.v.option.color=blue">Blue</a>

Sizing: <a href="/collections/sale?filter.v.option.color=black&filter.v.option.size=M">M</a> <a href="/collections/sale?filter.v.option.color=black&filter.v.option.size=L">L</a>

Sizing looks good to me, color nope. Now let's click on Blue, this is what happen:

Colors: <a href="/collections/sale?filter.v.option.color=blue&filter.v.option.color=black">Black</a> <a href="/collections/sale?filter.v.option.color=blue&filter.v.option.color=red">Red</a> <a href="/collections/sale?filter.v.option.color=blue">Blue</a>

Sizing: <a href="/collections/sale?filter.v.option.color=bluefilter.v.option.size=M">M</a> <a href="/collections/sale?filter.v.option.color=bluefilter.v.option.size=L">L</a>

So if the filter is a different filter, the url looks good as expected, both sizing filters are perfect, but within the same filter is not assembling the url correctly. Bottom line I think that this is a bug. Is there a way that this can be used? Am I missing something?

Let me know if you have ideas.

lpelati avatar Jan 18 '22 11:01 lpelati