Hide specific variants when sold out

Certain variants of my products are stocked only occasionally. I’d like to hide those variants when they are sold out. So far, the apps I am finding allow me to hide certain variants regardless of inventory OR all variants when sold out. I’d like to hide only certain variants (either hand-selected or by a rule, like all variants where size=large) when they are sold out. Does anyone know of a solution?

Hello @swamptromp ,

In your product template (or the section/snippet that loops through product.variants), wrap the option in a condition that checks both inventory and the option value. For example:

{% for variant in product.variants %}
{% assign is_large = variant.option1 == ‘Large’ %}
{% if variant.available or not is_large %}

{{ variant.title }}{% unless variant.available %} (Sold out){% endunless %} {% endif %} {% endfor %}

What this does:

  • It checks if the variant’s first option (adjust option1 to whatever you use for size) is “Large.”

  • If it’s Large and sold out (variant.available is false), it skips rendering that .

  • All other variants still show up, even if they’re sold out.

If you want to hand‑pick variants instead of using a rule, you could add a custom tag or metafield on the product like hide_when_sold_out: large, then check that instead of variant.option1. This way, you don’t have to hide every sold‑out variant and the ones you want to.

1 Like

Hey! This is a great question contributing to Shopify’s blog as a security-focused brand is actually a really smart move, especially now when digital storefront safety is becoming more important than ever.

I’ve worked with a few Shopify-based brands in similar industries, and getting visibility starts with understanding how your current presence aligns with what Shopify likes to feature (brand voice, UX, authority, etc.).

Would you mind dropping your store link? I’d love to take a quick look and maybe give you a few suggestions that could strengthen your pitch sometimes a small tweak in messaging or setup makes a big difference in getting featured.

Happy to help however I can!

Third-party apps make it easy to separate variants. I own the Stamp – Collection Variants app , and we help merchants display variants separately on the collection page. You can customize the settings per collection to show or hide specific variants, filter variants, or separate them by specific options. For example, you can create a “Gold” collection and display only gold-related variants.

What exactly is the process for doing this? I have never messed with metafields, but this would be incredibly helpful for me. I took a quick peek and the page seemed very daunting compared to the simplicity of your message. Thanks in advance!

Hi @swamptromp ,

Based on the instructions from Kudosi-Carlos Merchant, have you been able to implement it? If not, could you please send me the code from your main-product.liquid file? I will make the necessary adjustments and send it back to you with notes on how to customize it further.

Best,

Felix

Hi, this process is a bit too complex to explain here, so I’ve sent you a direct message. Please check your inbox!

You can do this with conditional logic in Liquid, or with apps such as Variant Option Product Options or Advanced Product Options, that support hiding variants based on stock rules. For something more flexible, custom code can be written that begins to target certain option values, such as size large, and hides them when the stock for them is zero. Goodluck.