fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Disable Ajax Variation Threshold not working

Nguyen Dung

I add this code to child theme’s functions.php but it now work

add_filter( 'woo_variation_swatches_global_ajax_variation_threshold_max', 'woo_variation_swatches_global_ajax_variation_threshold_max_edit', 10, 2 );
function woo_variation_swatches_global_ajax_variation_threshold_max_edit( $size, $product ){
return 700;
}

You can check it here:

https://gearcustoms.com/product/halloween-mom-to-be-mommys-little-bump-kin-personalized-t-shirt-gift-for-expecting-mom/

 

Hakik Zaman

Hi Nguyen,

Thanks for reaching out to us.

Could you record me reproducing your issue using a tool like this? https://www.useloom.com
It helps me to quickly figure out the issue.

Thank you

Hakik Zaman

Hi Nguyen,

Unfortunately, it is the default behavior of WooCommece.

The AJAX call will be fired when a product has 30 variations or more.

So it could cause your site to slow if you increase the threshold.

You can try the following snippet using the Code Snippets plugin:

add_filter( 'woocommerce_ajax_variation_threshold', 'woo_variation_swatches_global_ajax_variation_threshold_min', 10, 2 );
function woo_variation_swatches_global_ajax_variation_threshold_min( $size, $product ){
return 100;
}

Note: It is not recommended, do it at your own risk. No objection will be granted if you face any issues regarding this.

Thank You