1
votes

After updating Woocommerce to 2.6.12 my variable products are acting up on the frontend. For example I have a variable product with attributes for size and color. Not all colors are available in every size. Before the update Woocommerce would use AJAX to filter out incompatible choices in the next dropdown to prevent selecting products that don't exist. Now it shows all options whether they result in a valid product or not. Selecting an invalid product results in an alert box popping up stating:

Sorry, no products matching your selection. Please choose a different combination.

How can I make Woocommerce filter out the invalid attribute selections again?

2

2 Answers

7
votes

This probably is due to the woocommerce_ajax_variation_threshold. If your product contains more variations than the threshold specifies, woocommerce will wait until all variation options have been selected by the user before determining if the selected combination of options is valid(in stock, exists, etc).

Just set the threshold to a higher value. If your product has 30 possible combinations(whether they actually exist or not) set the threshold to something higher than 30, like 1111 for example.

You can use the snippet below in your functions.php file.

/* Increase Woocommerce Variation Threshold */
function wc_ajax_variation_threshold_modify( $threshold, $product ){
  $threshold = '1111';
  return  $threshold;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ajax_variation_threshold_modify', 10, 2 );
-1
votes

I've found the fix looking through Woocommerce's github repo closed issues. This user had the same issue. The fix can be found here. I downloaded the fix contained in the zip file and used it to replace the files found in /wp-content/plugins/woocommerce/assets/js/frontend/. After refreshing the page the invalid choices get filtered out and everything works as normal again.