Filtering Search Results? Is this really not possible?

Tourist
6 0 3

I have found that you can filter by adding something like "tag:whatever" to the search query. For example you'd search "sweater tag:kids" to get all sweaters with the tag of kids.

I haven't been able to get it working as a hidden field yet though which is what I really want. A query parameter for it would be really useful. The list of available query parameters is pretty limited https://shopify.dev/tutorials/use-advanced-query-parameters-in-shopify-online-store-search.

Filtering the results using liquid on the results page doesn't work because the first page could be blank since pagination sees items, you just aren't rendering them.

Update with my hacky solution: This adds the tag before the search submits, I then remove the tag from the search results when they're rendered. 

window.onload = function() {
      document.getElementById('searchform').onsubmit = function() {
        var txt = document.getElementById('query');
        txt.value = txt.value + ' tag:adult';
      };
    }

 

0 Likes
Excursionist
21 1 0

Any solutions for this?>

0 Likes
Tourist
6 0 3
Probably not one you’re gonna like...

I used JavaScript to capture the form submission and manually add a tag filter to the search query before sending it.
0 Likes
Excursionist
21 1 0

LoL, you're right....

We'll cross the bridge when we get there

0 Likes
Excursionist
21 1 0

is the tag filter you add a wild card? is there a wild card filter we can add or to the similar so it later displays the drop down of filter/sort by

0 Likes