Users report that Shopify’s Search & Discovery app displays products in collection filters even when specific sizes are out of stock, creating poor user experience when customers discover unavailability only on product pages.
Proposed Solutions:
Shopify Flow automation: Use Flow to dynamically add/remove tags or metafields based on inventory changes, ensuring filters only show in-stock variants. One user shared a Flow setup using Liquid code to update product metafields when inventory quantities change.
JavaScript modification: Modify the createSearchParams function in facets.js (or theme.js for some themes like Focal) to automatically append the availability filter (filter.v.availability=1) when size filters are active. This forces the system to show only in-stock items.
CSS hiding: Use JavaScript to check the in-stock filter by default on page load, then hide it with CSS if desired.
URL parameter workaround: Append ?filter.v.availability=1 to collection URLs by default using Shopify’s string filters.
Current Status:
No native solution exists within Search & Discovery. Shopify support has confirmed they have no built-in fix for this issue. Multiple users express frustration that such basic filtering functionality requires custom code or third-party apps. The discussion remains active with users seeking simpler, non-technical solutions.
Summarized with AI on October 29.
AI used: claude-sonnet-4-5-20250929.
I’ve seen a few posts on this issue, but a solution seems outstanding…
I have utilised filters for my online store originalweekend.com.au through the Search & Discovery App, as well as successfully creating metafields.
However… the SIZE filter, through Search & Discovery, shows all product that ever had that size available when filtered on the store. For example I have a t-shirt in 5 sizes, only size M, L, XL is available, S is sold out but when filtering according to size S that t-shirt will still come up as an option in the collection page, for the customer to then find it is not available on the product page.
This is obviously terrible UX, the filtering system is obviously flawed.
How can I set this up to only show sizes in stock when filtering by size?
If I can’t edit the Search & Discovery Size, do I then need to create a metafield and track this manually when product becomes available or not?
Looking forward to seeing if anyone has any solutions!
My solution was to use Shopify Flow to assign & delete tags when inventory changes, so they simply wont show in filters. Say, there is size S, M and L, but only M is available, so Flow will delete S and L tags until they are restocked. Therefore, when people would filter by size L they wont see this product, but it will appear if filtered by M.
Now, since we moved from using tags to metafields, I implemented similar way of filtering - assign metafields via Flow (for variant options, such as sizes etc.), but they are not deleted when inventory quantity for that variant drops below 1, because Shopify Search & Filters allows to add an additional filter option called Availability - In stock / Out of Stock.
That`s an extra strep for customers, which is not very pleasing, so we are thinking of using same structure as with tags - add metafields when in stock & delete when out of stock.
You can add a class for soldout products and hide them. But if you want to hide them only when the filter is active, you can add a class to the body to know when the filter is active.
Or to be more convenient, just use some 3rd party app, you can try this one https://apps.shopify.com/ultimate-search-and-filter-1
Sure, product variant metafields can`t be used to filter products in admin, but you can use Shopify Flow to add / remove tags alongside with metafields to be able to filter them in admin, if you need that.
It doesn’t work if you have multiple options. Like color and size. Changed my logic to use default shopify filter “in stock” and every time customer use filter automatically preselects it.
I have a quick trick/workaround: Apply the Availability filter to the url by default, using Shopify’s string filters. For example: if the childlink.type == ‘collection_link’, then href="{{ childlink.url | append:‘?filter.v.availability=1’ }}". Same thing for the ‘Remove all filters’ link. Unless the customer chooses to see out-of-stock products by modifying the Availability filter.
Hi, I’m having the same problem with my store. I wanted to try to solve with your script, but what do you mean with the facets.js file? I’ve searched but can’t find it.