WordPress + Woocommerce: hide unavailable variations when there are 2 attributes

I have a variable product in WordPress + WooCommerce and it has 2 attributes: color and size.

I’d like that when I select one of these 2 attributes, the unavailable variations with the second attribute will be automatically hidden (or unselectable) from the attribute select menu.

Read More

Is it possible? How can I achieve that?

I haven’t found any plugin that can do that. I’m trying to figure out what part of code to edit, but it’s quite a difficult task…

Related posts

Leave a Reply

1 comment

  1. I ran into your (old) question as i had it too. This is a working solution.
    Change ‘return 10’ to a number higher than your total amount of variations.

    Add it to your function.php file:

    function custom_wc_ajax_variation_threshold( $qty, $product ) {
        return 10;
    }
    
    add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );