Recently a client had an issue where Woocommerce product variations on the front end stopped working when there were more than 30 variations for the product. Fortunately there’s an easy fix for this bug.
WooCommerce by default uses a streamlined ajax threshold to populate the dropdowns on the product, but this streamlining can be restrictive since it’s set to a limit of 30 products. To fix this, we’ll be hooking to the woocommerce_ajax_variation_threshold filter.
Add the following code to your child theme’s functions.php and the limit will be raised to 100. Change the return value if you need more.
add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ninja_ajax_threshold' ); function wc_ninja_ajax_threshold() { return 100; }
Thanks for this – realised today after 50 variables that it was not switching the right colours when used alongside an additional dropdown variable.
This is fixed – thank you very much!
Where do you add that code? The functions.php file is very large.
Adding it at the bottom will be fine. :)
thx!
thanks
Holy crap! Thank you so much! I have been trying to figure this out for the past two days! Woo can be such a pain in the but sometimes.