You can grey out out-of-stock variations in WooCommerce with one filter that disables unavailable options directly in the variation dropdown, so customers see stock status before they even select a variation.
Why Disable Out-of-Stock Variations Upfront
- Prevents the frustration of picking a variation only to learn it’s unavailable afterward
- Greyed-out options communicate stock status without extra UI work
- A single filter, no template overrides required
- Works alongside any theme’s default variation dropdown
Step 1: Disable Out-of-Stock Variations in the Dropdown
/** Grey out and disable variation options that are out of stock */
add_filter( 'woocommerce_variation_is_active', 'disable_out_of_stock_variation_options', 10, 2 );
function disable_out_of_stock_variation_options( $is_active, $variation ) {
if ( ! $variation->is_in_stock() ) {
return false;
}
return $is_active;
}Combining It With a Custom “Out of Stock” Label
The filter alone only disables the option in the dropdown — it doesn’t append any visible text. Many stores pair it with a small jQuery snippet that appends “(Out of Stock)” to the disabled option’s label, so shoppers immediately understand why that choice can’t be selected instead of just seeing it greyed out with no explanation.
Troubleshooting
Variations are disabled but there’s no visual indication why
The filter disables the option but doesn’t automatically add a label — add a small CSS rule to style disabled <option> elements distinctly, or use a variations-swatches plugin if you want visible “Out of Stock” labels directly in the UI.
All variations show as disabled unexpectedly
Check whether stock management is actually enabled on the individual variations, not just the parent product — if variation-level stock tracking is off, is_in_stock() may return unexpected results.
Frequently Asked Questions
Does this hide out-of-stock variations completely?
No, it disables (greys out) the option rather than removing it — customers can still see the variation exists, just can’t select it while unavailable.
Will restocking automatically re-enable the variation?
Yes, since the filter checks live stock status on every page load, a variation becomes selectable again as soon as its stock status updates.
Does this affect simple (non-variable) products?
No, this filter only applies to variation objects on variable products — simple product stock display uses separate logic entirely.
Conclusion
One filter is all it takes to grey out out-of-stock variations in WooCommerce, saving customers from picking an option that can’t actually be purchased. Pair it with a small CSS tweak if you want the disabled state to stand out more clearly in your theme.
See also How to Set Up a Waiting List for Out-of-Stock Products in WooCommerce. Then read How to Display All Product Variations With a Shortcode in WooCommerce.
Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.