managed wordpress hosting

Woocommerce Variation Threshold


On 03-10-2021 articles, code, WooCommerce, wordpress

If your Woocommerce store has a lot of variations with specific attributes you might come across an instance when the options are not displaying properly. It’s showing everything instead of only assigned variation for an attribute. And yet when you pick a combination of something that’s should be hidden you get this message.

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

Now a quick Google search might tell you that you have some “orphan” variations that might be causing the issue. This could be the case in which you want to go into Woocommerce settings and delete orphans.

Woocommerce > Status > Tools (tab) > Delete Orphaned variations

But more than likely the real issue is that Woocommerce has decided in the background without notifying you that it’s decided to not function like it should for performance improvement. You have met a threshold! And all the trouble shooting in the world won’t save you. Luckily I have spent 3 days finding this out the hard way and have your remedy.

If your backend appears as it should but the front end isn’t working as intended you can quickly check the html to see if the varations are getting added.

<form class="variations_form cart" action="https://localhost/product/test-fresh-product/" method="post" 
      enctype="multipart/form-data" data-product_id="9" data-product_variations="false" current-image="" style="zoom: 1; position: static;">

Product Variations is the give away. If it’s set to false then you have meet the threshold. Assuming you have it setup properly in Woocommerce.

data-product_variations="false"

If you see this set to false and you clearly have attributes with many variations then add this code to your functions.php. Adjust the 50 if need to depending on how many variations you have. (if you are using a paid theme that gets updates you will need to roll out a child theme and then add the functions.php in the child theme directory)

add_filter( 'woocommerce_ajax_variation_threshold', 'tweak_wc_inc_ajax_threshold' );
function tweak_wc_inc_ajax_threshold() {
    return 50;
}