Woocommerce Hide Variations which are not possible

2.6k views Asked by At

I have a lot of product variations … 50 at the moment. In the first Dropdown, you can either select Single or Double. In the second Dropdown, you can select the picture frame size.

And here is what I don't get … the size 23x23 and 50x50 is only available for Single Pictures. But when I select Double I am able to select 23x23 and 50x50 just to get the information that this variation is not possible.

I am looking for a solution that when I select Double I am not even able to select nor see 50x50.

I have found this post but the code is not working for me: Hide variations that don't match

It seems to be a common problem but there is not really a solution.

1

There are 1 answers

0
Marin On

It is because Woocommerce limits the max variations to 30.

Here is the code with which I managed to solve it:

function custom_wc_ajax_variation_threshold( $qty, $product ) {
    return 50; // Increase default 30 to 50
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 100, 2 );