Hide sold-out products and unavailable variants on Shopify
To hide sold-out variants, add one CSS rule to your theme’s Custom CSS (Horizon or Dawn) so unavailable sizes and colors disappear from the picker. To hide out-of-stock products, add the condition “Inventory stock is greater than 0” to your automated collections; this page writes the update for all of them at once, with an undo.
What you’ll need
A duplicate of your theme to test on
How to get this: A duplicate of your theme to test on
- Online Store › Themes › … on your theme › Duplicate.
- Make the change on the copy, preview it, and publish only when it works.
The theme editor (to add a Custom Liquid block; no code editing)
How to get this: The theme editor
- Online Store › Themes › Edit theme (on a copy of your theme if you want to test first).
- Add section or Add block › Custom Liquid, paste the code, then Save.
Shopify’s free GraphiQL app (with read_products, write_products (for the collections step) access)
How to get this: Shopify’s free GraphiQL app
- Install it once from shopify-graphiql-app.shopifycloud.com: enter your store address, tick the access listed here, click Install and approve.
- Then open it any time from Apps › Shopify GraphiQL App in your admin.
1Hide sold-out variants in the picker
Online Store › Themes shows your theme’s name under Current theme.
With two options, a size that’s sold out in the chosen color hides until the customer picks another color.
Easiest: paste into Custom CSS (buttons and swatches)
- Online Store › Themes › Customize (on a copy of your theme to test first).
- Open Theme settings (the gear icon) › Custom CSS, paste the code and click Save.
- Open a product with a sold-out size: it’s gone from the picker. The selected value always stays.
/* Easy Store Tools: hide sold-out variant buttons and swatches (Horizon) */
.variant-option__button-label:has(input[data-option-available="false"]:not(:checked)) {
display: none;
}Use drop-downs? Add one line of Liquid instead
CSS can’t hide drop-down choices on every browser. On a copy of your theme, open … › Edit code › snippets/variant-main-picker.liquid, find {%- for product_option_value in product_option.values -%} and paste this line right after it. The line appears twice (buttons, then drop-downs): paste after each. It hides unavailable buttons, swatches and drop-down choices.
{%- if product_option_value.available == false and product_option_value.selected == false -%}{%- continue -%}{%- endif -%}2Hide out-of-stock products from your collections
Adds “Inventory stock is greater than 0” to every automated collection that matches all conditions. Products leave the collection at 0 and come back when restocked. The undo puts each collection’s conditions back exactly as they were.
a. Copy this query and run it in the GraphiQL app
It only reads. Install the app once from Shopify’s GraphiQL app setup with read_products and write_products.
# Easy Store Tools: list your automated collections and their conditions (read-only)
query AutomatedCollections {
collections(first: 250, query: "collection_type:smart") {
nodes {
id
title
handle
ruleSet {
appliedDisjunctively
rules { column relation condition }
}
}
pageInfo { hasNextPage endCursor }
}
}b. Paste the reply
3Hide them from search
Search has its own setting in Shopify’s free Search & Discovery app: Apps › Search & Discovery › Settings › Out of stock products. Choose to hide them, show them last (Shopify’s default), or show them normally. It covers the search page and predictive search, not collections.
How it works
- Pick your theme and paste the CSS into Theme settings › Custom CSS, or add the one Liquid line for drop-downs.
- Run the read-only query in the GraphiQL app and paste the reply.
- Untick any collection you want to leave alone, then run the update. Keep the undo.
- Set Search & Discovery › Settings › Out of stock products to hide or show last.
Guides
Questions
Does Shopify have a setting to hide out of stock products?
Only for search: Search & Discovery › Settings › Out of stock products (show, hide or show last). Collections need the condition “Inventory stock is greater than 0”, and variant pickers need a small theme change. This page builds both.
Will hidden products come back when I restock?
Yes. The collection condition is checked continuously: a product leaves the collection at 0 and comes back when it has stock again. The variant CSS reads availability on every page view.
Why is a product with stock still hidden, or a sold-out one still showing?
The collection condition adds up Available stock at every location, including ones that don’t sell online, and it ignores Continue selling. So a product with stock only at a location that doesn’t fulfill online orders stays in the collection, and a pre-order product at 0 is removed.
Does it work on manual collections?
No. Conditions only exist on automated collections. For manual collections, the Sold-out to Bottom tool moves sold-out products to the end instead.
Is anything uploaded?
No. The page builds code in your browser; you run it in Shopify’s GraphiQL app or paste it into your theme yourself.
Based on Shopify’s guide to hiding out of stock products and Search & Discovery settings.
Related: Sold Out Diagnoser · Sold-out to Bottom · Collections Bulk Builder · Liquid Snippet Studio