Support » Plugin: WooCommerce » Product variations: how to exclude sizes unavailable?

  • Hi Guys

    I have an issue i havnt noticed before but it drives me crazy.

    I have these products on my page in different colors and sizes fx these trousers i link to.

    My problem is that the different colors do not come in the same sizes which means that if the customer chose the size it still shows all the colors from every variation even though the color they chose doesnt have that specific size so a popup will activate and tell them that the size and color match doesnt exist. This leaves my customers to have to try different combinations until they find one that exists which is a waste of time. How do i solve this?

    Try fx putting in size 21 in “hvid/White” and you will see the popup. after chosing size 21 i just want it to only shows the colors this comes in.

    • This topic was modified 4 years, 9 months ago by Hampmir.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • See:

    The variations “threshold” is usually 30, though that can vary by theme. If you have less variations than the threshold, all the variations are loaded with the page, and unavailable variations cannot be selected. If you have more variations than the threshold, any combination can be selected, then ajax will be used to find out if the selected variation is available, and sometimes its not.

    You can increase the variations threshold using this snippet in functions.php for your child theme:

    As you make the threshold bigger, the page size gets bigger so page load time will increase. You’ll need to make a judgement.

    Thread Starter Hampmir


    oh cool, is that the collective variations threshold that is 30 or is it maximum of 30 sizes per color? šŸ™‚

    also, could this be the reason why size 23 is showed as 2/3? šŸ™‚

    • This reply was modified 4 years, 9 months ago by Hampmir.

    Collective. It looks like you have up to 35 x 4 = 140 variations on the page, less any that you don’t supply, so set the threshold to 150 and test.

    I don’t think its anything to do with the 2/3 issue. Not seen that before.

    Thread Starter Hampmir


    Thank you i would never have found out about this myself šŸ™‚

    I have no experience in PHP coding so i dont want to mess with that and i have no child theme, i program the custom css from DIVI builder. I solved the problem the lazy way and just deleted all the sizes that didnt include all the colors so i only have the sizes that is available in every color let, those should be the most sold anyway šŸ™‚

    OK, but if you want to try again…

    If you have no child theme you can use this plugin:

    Copy and paste this text into plugin settings where it says “Functions (PHP code)”

    function ww_ajax_variation_threshold( $default, $product ) {
      return 150; // increase this number if needed
    add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );
    Thread Starter Hampmir


    I have now installed the plugin but when i enter the code it says “this code causes a fatal error so it is not applied” šŸ™‚

    but this may not be the reason, as you can see i have now deleted a lot of variation and are down under 30, but this still occurs

    • This reply was modified 4 years, 9 months ago by Hampmir.
    Thread Starter Hampmir


    Sorry my fault it seems i made a mistake when i pasted it, this works perfect, thank you very much! now i just need to find out why some numbers are split, like the 2/3 error šŸ˜€

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Product variations: how to exclude sizes unavailable?’ is closed to new replies.