{"product_id":"2026-08-19","title":"Auto-record stock status to a metafield with Shopify Flow and use it as a Search \u0026 Discovery filter","description":"\u003cp\u003e\u003cspan\u003eThe built-in \"Availability\" filter in Search \u0026amp; Discovery looks at inventory per variant. So a product shows up under \"Out of stock\" as soon as a single variant runs out — a shirt whose only sold-out size is S ends up listed next to genuinely sold-out products.\u003c\/span\u003e\u003c\/p\u003e\n\u003cp\u003eThe URL parameter explains why. The built-in filter is \u003ccode\u003efilter.v.availability\u003c\/code\u003e, and the \u003ccode\u003efilter.v.\u003c\/code\u003e prefix means the scope is the variant, not the product. \u003ccode\u003e0\u003c\/code\u003e means out-of-stock variants and \u003ccode\u003e1\u003c\/code\u003e means in-stock variants, so a product with a mix of both matches \"In stock\" and \"Out of stock\" at the same time.\u003c\/p\u003e\n\u003cp\u003eThere is no built-in way to ask \"is every variant sold out?\" at the product level. So you keep your own product metafield for stock status, let Shopify Flow maintain it, and filter on it as a \u003ccode\u003efilter.p.\u003c\/code\u003e (product-level) filter. It reads \"Out of stock\" only once every variant has become unavailable, and returns to \"In stock\" as soon as any variant has stock again.\u003c\/p\u003e\n\u003cp\u003e\u003cimg alt=\"Result: filtering products by stock status\" src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19_1_en.png?v=1787033666\" class=\"zoomable-image\" style=\"max-width:100%;height:auto;\"\u003e\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003eWhat this setup involves\u003c\/h3\u003e\n\u003cp\u003e◆Create a product metafield that holds the stock status\u003cbr\u003e◆Build a Flow that watches inventory changes and rewrites that value\u003cbr\u003e◆Add a Search \u0026amp; Discovery filter whose source is that metafield\u003c\/p\u003e\n\u003cp\u003eBecause the logic lives in Flow, you can move away from \"only when everything is sold out\" to whatever rule you need. You also control the label, and you can add extra states such as \"Backorder\" or \"Pre-order\" later. The built-in filter allows none of that.\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003e[Step 1] Create the stock status product metafield\u003c\/h3\u003e\n\u003cp\u003e◆Shopify admin → Settings → Custom data → Products → Add definition\u003cbr\u003e◆Name it \"Stock status\" and pick the type \"Select list (single line text)\"\u003cbr\u003e◆Register \"In stock\" and \"Out of stock\" as the validation choices\u003cbr\u003e◆Turn on \"Storefront API access\" under Options\u003c\/p\u003e\n\u003cp\u003e\u003cimg alt=\"Step 1: the product metafield definition\" src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19_2_en.png?v=1787029314\" class=\"zoomable-image\" style=\"max-width:100%;height:auto;\"\u003e\u003c\/p\u003e\n\u003cp\u003eIf Storefront API access stays off, the metafield will not appear as a filter source in Step 3. It is the easiest part to miss, so it is worth confirming up front.\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003e[Step 2] Build the Flow that watches inventory\u003c\/h3\u003e\n\u003cp\u003e◆Shopify admin → Apps → Flow → Create workflow\u003cbr\u003e◆Trigger: Product variant inventory quantity changed\u003cbr\u003e◆Condition: pick \u003ccode\u003eproduct \/ variants\u003c\/code\u003e, set the list operator to \"All of\", and check that \u003ccode\u003eavailableForSale\u003c\/code\u003e is False\u003cbr\u003e◆On the True branch, add \"Update product metafield\" and set Stock status to \"Out of stock\"\u003cbr\u003e◆On the False branch, add the same action and set it to \"In stock\"\u003c\/p\u003e\n\u003cp\u003e\u003cimg alt=\"Step 2: the Flow condition and its two branches\" src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19_3_en.png?v=1787029314\" class=\"zoomable-image\" style=\"max-width:100%;height:auto;\"\u003e\u003c\/p\u003e\n\u003cp\u003eThe operator list still contains \"All of … or list is empty (deprecated)\". It treats an empty list differently, so pick the one without the (deprecated) suffix. The \u003ccode\u003e.flow\u003c\/code\u003e file shown after purchase lets you import this workflow as it is.\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003e[Step 3] Add the filter in Search \u0026amp; Discovery\u003c\/h3\u003e\n\u003cp\u003e◆Shopify admin → Apps → Search \u0026amp; Discovery → Filters → Add filter\u003cbr\u003e◆Choose \"Product metafield: Stock status\" as the source\u003cbr\u003e◆Type the label you want customers to see\u003cbr\u003e◆Save\u003c\/p\u003e\n\u003cp\u003e\u003cimg alt=\"Step 3: the Search \u0026 Discovery filter settings\" src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19_4_en.png?v=1787029314\" class=\"zoomable-image\" style=\"max-width:100%;height:auto;\"\u003e\u003c\/p\u003e\n\u003cp\u003eYou can leave the built-in Availability filter in place, or drop it and keep only this one if having both is confusing.\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003eWhy totalInventory must not decide stock status\u003c\/h3\u003e\n\u003cp\u003eIt is tempting to use \u003ccode\u003eproduct.totalInventory\u003c\/code\u003e in the Flow condition, but it excludes variants whose inventory is not tracked. Such a variant can be bought without limit, yet it contributes zero to the total. Deciding \"out of stock when the total is zero or less\" therefore flags products that customers can still buy.\u003c\/p\u003e\n\u003cp\u003e\u003cimg alt=\"How totalInventory and availableForSale differ\" src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19_5_en.png?v=1787029314\" class=\"zoomable-image\" style=\"max-width:100%;height:auto;\"\u003e\u003c\/p\u003e\n\u003cp\u003e\u003ccode\u003eavailableForSale\u003c\/code\u003e is Shopify's final answer to whether a variant can be bought right now. It already accounts for inventory tracking, the continue-selling-when-out-of-stock setting, and the quantity, so it is the only value you need to read.\u003c\/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c\/p\u003e\n\u003ch3\u003eThings to watch in day-to-day use\u003c\/h3\u003e\n\u003cp\u003e◆Flow only runs at the moment inventory changes. Existing products get no value, so you need one bulk backfill at the start\u003cbr\u003e◆A filter value with zero matching products disappears from the storefront filters\u003cbr\u003e◆Search \u0026amp; Discovery allows up to 25 filters per store\u003c\/p\u003e","brand":"STORE DOJO","offers":[{"title":"Default Title","offer_id":49190940639483,"sku":null,"price":0.0,"currency_code":"USD","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0733\/0381\/8491\/files\/2026-08-19-thumb.png?v=1787092298","url":"https:\/\/store-dojo.com\/en-us\/products\/2026-08-19","provider":"STORE DOJO","version":"1.0","type":"link"}