WooCommerce Modify Ajax Variation Threshold

When your variable product has more than 30 variations, WooCommerce starts to use ajax to load your selected variation. This changes the way the dropdown fields work – where before you could select some options and others would become unavailable/disabled, now you have to select all options before finding out the variation you selected is not available. You may have noticed this when using our WooCommerce Variation Swatches plugin to change your product dropdowns into graphical swatches.

Fortunately, as with most things WooCommerce, you can modify this setting. Try adding this to your theme’s functions.php file:

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

This means ajax will only kick in when there is more than 50 variations. You can adjust this accordingly.

You could also use the  $product object to do this for a specific product only. Very useful!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.