← KABAA Swatches blog
woocommerce guide

How to grey out out-of-stock variations in WooCommerce

By default WooCommerce lets shoppers pick a size or colour that is sold out, and only says “Out of stock” afterwards. Here is how to grey those options out or hide them, with or without a plugin, and why the usual fix stops working on products with more than 30 variations.

By Kazi Badrul Alam, developer of KABAA Swatches · Updated 17 October 2026 · Tested against WooCommerce 10.9

Short answer

To grey out out-of-stock variations, add a filter on woocommerce_variation_is_active that returns false for variations that are not in stock. To hide them instead, turn on Hide out of stock items from the catalog. Both work only on products with 30 variations or fewer. Above that, raise the limit with woocommerce_ajax_variation_threshold, or use a swatch plugin that checks stock itself.

What WooCommerce does by default

WooCommerce’s variation dropdowns remove combinations that don’t exist. If there is no “Red / XL” variation, choosing Red removes XL from the size list.

A combination that exists but is out of stock is treated differently: it stays selectable. The shopper picks it, and only then sees “Out of stock” with the add to cart button disabled. On a product with many sizes and colours, that means a lot of dead ends. Greying out sold-out options shows shoppers what they can actually buy before they choose.

Grey out out-of-stock variations without a plugin

WooCommerce asks every variation whether it is “active”. Inactive variations still exist, but the options that lead only to them are disabled, which is the greyed-out look. By default every variation answers yes. This filter makes out-of-stock ones answer no:

/**
 * Grey out out-of-stock variations in the variation dropdowns.
 * Add to your child theme's functions.php or a code snippets plugin.
 */
add_filter( 'woocommerce_variation_is_active', function ( $active, $variation ) {
	return $variation->is_in_stock() ? $active : false;
}, 10, 2 );
  1. Add it to your child theme’s functions.php, or to a code snippets plugin. Don’t add it to the parent theme, which would lose it on the next update.
  2. Open a product with a sold-out variation and choose an option. Sold-out options now show greyed out and can’t be selected.
  3. Variations set to allow backorders count as in stock, so they stay selectable. That is usually what you want, because they can still be bought.

How a disabled option looks is up to the browser and your theme. Usually it is grey text in the dropdown. If it shows on some products and not on others, see the 30-variation limit.

Hide out-of-stock variations instead

To remove sold-out options completely instead of greying them out, go to WooCommerce › Settings › Products › Inventory and tick Hide out of stock items from the catalog. WooCommerce then leaves out-of-stock variations out of the variation form altogether.

Two things to know before choosing this:

  • The same setting also hides out-of-stock products from your shop and category pages, not just variations.
  • Shoppers can’t see that a size or colour exists, so they don’t know to come back for it. Greying out keeps it visible.

Not working? The 30-variation limit

If the snippet or the hide setting works on most products but not on one, count that product’s variations. It almost certainly has more than 30.

When WooCommerce draws the variation form, it compares the product’s total number of variations to a limit:

// woocommerce/includes/wc-template-functions.php
$get_variations = count( $product->get_children() )
	<= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );

Up to 30, WooCommerce prints every variation into the page, and the browser uses that list to remove, grey out and hide options as the shopper chooses. Above 30, it prints nothing (data-product_variations="false" in the page source) and looks a variation up only once every option has been chosen. Without the list, the browser has nothing to grey out with:

30 or fewer variationsMore than 30
Variation list in the pageYes, every variationNo
Combinations that don’t existRemovedStill selectable
Grey-out snippetWorksDoes nothing
“Hide out of stock items”Hides sold-out optionsHides nothing in the form
Stock checkedAs the shopper choosesAfter every option is chosen

WooCommerce does this on purpose: a product with 300 variations would otherwise put all 300, with their prices, images and stock, into every page view. But the result is that the products with the most options, where greying out helps shoppers most, are exactly where it stops working.

Raise the 30-variation limit

The limit has its own filter. Set it just above your largest product’s variation count, and the snippet and hide setting work on that product again:

/**
 * Send variation data to the page for products with up to 100 variations,
 * so out-of-stock options can be greyed out on them too.
 */
add_filter( 'woocommerce_ajax_variation_threshold', function ( $threshold, $product ) {
	return 100;
}, 10, 2 );

The cost: every view of those products now loads all their variations on the server and prints them into the page. That’s fine at 60 variations and noticeable in the hundreds. After raising it, check your largest product page’s size and load time. The filter receives the product, so you can raise the limit only for the products that need it.

Use a swatch plugin that handles it

A variation swatches plugin replaces the dropdowns with colour, image or button swatches, and most can cross out, blur or hide out-of-stock options. Above 30 variations, though, they have the same problem as the snippet. Most either stop marking stock there, or offer a setting that raises the limit, with the same page-weight cost.

WooCommerce shop cards with colour swatches where out-of-stock options are crossed out, made with KABAA Swatches.
Out-of-stock options crossed out on swatches, with KABAA Swatches.

KABAA Swatches, which I build, works on products of any size without raising the limit. Up to 30 variations, it uses the list WooCommerce already printed and sends no request. Above that, it keeps a cached record of which combinations can be bought, cleared whenever stock changes, and asks only about the swatches on screen. A product with 400 variations costs about the same as one with 40.

Out-of-stock options can be crossed out, blurred or hidden, on product pages and on shop cards. It needs WooCommerce 8.0+, PHP 8.0+ and a classic theme that uses WooCommerce’s standard variation form.

Free in KABAA Swatches, paid elsewhere

KABAA Swatches has no Pro version: every feature is in the free plugin. In the largest variation swatches plugins, several of the same features are part of a paid upgrade, according to their own WordPress.org listings.

Feature KABAA GetWooPluginsCartFlowsWCBoostVillaThemeRadiusThemeThemeHigh
Out-of-stock marking above 30 variations Free Pro Raises limit — — — Raises limit
Out-of-stock options marked Free Free Free Free Pro Free Free
Swatches on shop and category pages Free Pro Free Pro Pro Pro Pro
Add to cart from the shop page Free — — Pro Pro Pro —
Swatches for attributes made inside a product Free Pro — — — Pro —
Image swatches from the variation photos Free Free Free Pro Free — —
Pro version None YesNoneYesYesYesYes

From each plugin’s own WordPress.org listing, checked October 2026. — means the listing does not mention the feature. “Raises limit” means it handles big products by raising WooCommerce’s 30-variation limit, which makes those pages heavier.

WooCommerce variation swatches plugins compared

How each plugin handles out-of-stock variations, from its own WordPress.org listing, checked on 14 October 2026. The list covers every dedicated swatch plugin with 1,000+ active installs, plus smaller ones whose listing mentions the 30-variation limit. Not stated means the listing does not say. It does not mean the plugin fails, so test it on your largest product.

PluginOut-of-stock markingAbove 30 variations
KABAA Swatches
Kazi Badrul
Free: cross, blur or hide Free — works without raising the limit
Variation Swatches for WooCommerce
GetWooPlugins
Free: cross, blur or hide Pro — the free version handles up to 30 variations
Variation Swatches for WooCommerce
CartFlows
Free: blur, cross or hide Raises the limit to 200 (per its changelog)
Variation Swatches for WooCommerce
Woosuite / AovUp
Free Not stated
WCBoost – Variation Swatches
WCBoost
Free: hide or blur; disabling while visible is Pro Not stated
Product Variations Swatches
VillaTheme
Pro Not stated
Product Variation Swatches
ThemeHigh
Free: hide, blur or strike through Free setting that raises the limit
Variation Swatches for WooCommerce
RadiusTheme
Free: cross, blur or hide Not stated
Swatchly
HasThemes
Hiding is Pro Free setting that raises the limit
Variation Swatches Style
aThemeArt
Free Not stated
TH Variation Swatches
ThemeHunk
Free: blur or hide Not stated
YaySwatches
YayCommerce
Pro Not stated
QODE Variation Swatches
Qode Interactive
Not stated Not stated
Smart Swatches
ShapedPlugin
Free: cross or blur Pro setting that raises the limit
Enweby Variation Swatches
Enweby
Free: blur, cross or hide Free setting that raises the limit
Variation Swatches and Gallery
akdevs
Free: blur, cross or hide Free setting that raises the limit

If you maintain one of these plugins and the listing has changed, tell me through the contact page and I will update the row.

Frequently asked questions

How do I grey out out-of-stock variations in WooCommerce?

Add a filter on woocommerce_variation_is_active that returns false when the variation is not in stock. WooCommerce then disables the options that only lead to out-of-stock variations. It works on products with up to 30 variations; above that, raise the woocommerce_ajax_variation_threshold limit as well, or use a swatch plugin that checks stock itself.

Can I grey out out-of-stock variations without a plugin?

Yes. Two short filters in your child theme’s functions.php or a code snippets plugin do it: woocommerce_variation_is_active to grey them out, and woocommerce_ajax_variation_threshold for products with more than 30 variations.

How do I hide out-of-stock variations in WooCommerce?

Turn on “Hide out of stock items from the catalog” under WooCommerce › Settings › Products › Inventory. WooCommerce then leaves out-of-stock variations out of the variation form, so their options disappear. Like the snippet, this only works on products with up to 30 variations.

Why does the grey-out snippet not work on some products?

Those products have more than 30 variations. Above that limit WooCommerce does not print the variation list into the page, and the snippet only changes that list, so there is nothing for it to act on. Raising woocommerce_ajax_variation_threshold above the product’s variation count fixes it.

Is it safe to raise the 30-variation limit?

Up to a point. Every variation of the product, with its prices, stock and images, is then loaded and printed into the page on every view. Raise it just above your largest product rather than to a very large number, and measure that product page’s size and load time afterwards.

Why is my variable product showing out of stock?

WooCommerce marks a variable product out of stock when none of its variations is in stock or on backorder. Check each variation’s stock status and quantity under Product data › Variations.

Is there a free plugin that greys out out-of-stock variations?

Several free swatch plugins cross out, blur or hide out-of-stock options. KABAA Swatches does it on products of any size, including above 30 variations, and has no Pro version: swatches on shop pages, add to cart from the shop page and swatches for custom attributes are free too.