Help setting up flow to Filter Availability to only show Out of stock when all variants unavailable

I’m using the Focal version 12.4.0 and have a problem with the filters with Availability: Out of stock.
it includes any SKU that has a Variants the has gone out of Stock. I would only like to have included in this filter only items that have all available variants sold out included in this filter search.
Example:
products with different sizes will show up as ‘out of stock’. So for example they are still available in S and M but sold out in L

I have been reading that I could create a flow to fix this problem and need some help as to how i should create the flow to check product variants and add to availability - out of stock only when all variants are unavailable is it possible to setup a flow to fix this problem?

Hey @Manny-v .

Yes, you can use Shopify Flow to automate this, but Shopify Flow doesn’t directly modify filters in themes. Instead, you can use Flow to tag products as “out-of-stock” only when all variants are sold out. Then, update your filters to use this tag instead of Shopify’s default availability filter.

Steps to Set Up Shopify Flow:

  1. Trigger: “Product Variant Updated” or “Inventory Quantity Changed”

  2. Condition: Check if all variants of the product have inventory_quantity = 0

  3. Action:

  • If all variants are out of stock, add a tag like out-of-stock

  • If at least one variant is in stock, remove the out-of-stock tag

  1. Update Filters: Modify your theme’s filter settings to use the out-of-stock tag instead of Shopify’s built-in Availability filter.

Would you like help writing the Liquid code to adjust the filter in your Focal theme? Please feel Free to reach out!

Thanks!

Yes, this behaviour looks odd when applied on products, however, if you filter by both product option and availability it makes sense – say you’re looking for product which is “red” and “in stock” – then filtering goes on variant level.

As far as I know, it’s not possible to change the way Availability criteria works, but since you’ve mentioned Flow – it’s possible to remove Availability from filters and instead filter by custom product metafield which will be updated with flow each time variant inventory changes.

Basically, it’s triggered with “product inventory quantity changed” and the action is to update your custom metafield based on product.totalInventory > 0 or some other more complex condition you see fit.

Example flow to start with:

Hi,

Thank you for your reply i have setup the Flow :

and would like some help with writing the Liquid code to adjust the filter in your Focal theme I’m using the 12..4.0

The point of using metafield for this is that it will work out of the box with recent theme, just need to configure it in Shopify own Search & Discovery app.

And this is a metafield specifically created for this purpose, rather then tags, which you may already have and when filtering by tags you may end up showing more tags in selector then you wanted.