Shopify sold out guide

How to hide sold-out variants on Shopify (Horizon and Dawn)

What you’ll need

  • A duplicate of your theme to test on

    How to get this: A duplicate of your theme to test on
    1. Online Store › Themes › … on your theme › Duplicate.
    2. Make the change on the copy, preview it, and publish only when it works.

    Step-by-step guide (opens in a new tab)

  • The theme editor (to add a Custom Liquid block; no code editing)

    How to get this: The theme editor
    1. Online Store › Themes › Edit theme (on a copy of your theme if you want to test first).
    2. Add section or Add block › Custom Liquid, paste the code, then Save.

    Step-by-step guide (opens in a new tab)

  • Shopify’s free GraphiQL app (with read_products, write_products (for the collections step) access)

    How to get this: Shopify’s free GraphiQL app
    1. Install it once from shopify-graphiql-app.shopifycloud.com: enter your store address, tick the access listed here, click Install and approve.
    2. Then open it any time from Apps › Shopify GraphiQL App in your admin.

    Step-by-step guide (opens in a new tab)

Get the code for my theme

Horizon

Custom CSS (Horizon)
.variant-option__button-label:has(input[data-option-available="false"]:not(:checked)) {
  display: none;
}

Dawn

Custom CSS (Dawn)
.product-form__input input[type="radio"].disabled:not(:checked) + label,
.product-form__input .swatch-input__input.visually-disabled:not(:checked) + label {
  display: none;
}

Where to paste it

  1. Online Store › Themes › … › Duplicate, to test on a copy.
  2. On the copy click Customize, open Theme settings (the gear icon) and find Custom CSS.
  3. Paste the rule for your theme and click Save.
  4. Preview a product with a sold-out size: the size is gone, and the selected one always stays.

What the rules do

Both rules go in Theme settings › Custom CSS and save in Horizon and Dawn without errors. A sold-out value (say, Charcoal on a tote) disappears from the picker. With two options, a value hides only for the combination that’s sold out: if Oxblood 10 in is sold out, 10 in hides while Oxblood is picked and comes back when Natural is picked. The Liquid line passes Shopify’s theme code validation.

Two options (size and color)

Shopify works out “available” for each value given the other choices. With two options, a size that’s sold out in the chosen color hides, and shows again when the customer picks a color that has it. If that feels confusing, use the Liquid line with “only products with one option”.

More guides