Unavailable variations won’t hide in WooCommerce

WooCommerce by default already hides unavailable variations in products. However, this is limited to only 20 product variations — here’s a guide on how to increase this.

Increase the WooCommerce unavailable/hidden variation limit

In order to increase your hidden variation limit, you simply need the add the below code to your active WordPress theme’s functions.php file.

function custom_woocommerce_ajax_variation_threshold( $qty, $product ) {
     return 1000; // Set 1000 to another number to load faster
}

add_filter( 'woocommerce_ajax_variation_threshold', 'custom_woocommerce_ajax_variation_threshold', 10, 2 );

Note, by using 1000 (as per the above example), your website may load slower. Therefore, you should consider a lower number if speed is an issue.