• Resolved Nick Porter

    (@nickporter2)


    I have created a variable product the options are flavour and strength. Some of the products are available in both strengths but some are only available in one strength.

    So what I can’t figure out or even no if it is possible is if somebody selects say 0mg as the first option is it possible to have the flavour drop down show only the flavours available in a 0mg strength and not all the flavours?

    At the moment using the page link above I have the Apple Peach 0mg option set to out of stock ( but this is not true they don’t make it as a 0mg only a 20mg) and down at the bottom of the flavour list there Tobacco flavour again only available as 20mg ( I have deleted the 0mg option) but it is still showing up.

    Hope that makes sense.

    Thanks

    Nick

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • My understanding is that if there are fewer than 30 variations, WooCommerce does an AJAX call to adjust the options available so that only the available options are shown, but if your have more than 30 possible variations (multiply the number of flavors by the number of strength options), the AJAX adjustments are not made, and it will be possible to select variation combinations that don’t exist, resulting in a message that the product is not available.

    If that’s the problem you’re encountering (I got a 404 when I tried to look at the page, so I couldn’t tell) you can increase the AJAX variation threshold using the following filter in your child theme’s functions.php:

    
    add_filter('woocommerce_ajax_variation_threshold', 'wc_ajax_variations_threshold' );
    function wc_ajax_variations_threshold() {
        return X;
    }
    

    Replace the X with the number you want to increase the threshold to; e.g., if you have 40 variations, give it a little padding and use 45; the line would be:

    
    return 45;
    
    Thread Starter Nick Porter

    (@nickporter2)

    Thanks for your reply I will give that a try.

    Cheers

    Nick

    Hi there @nickporter2

    Just wanted to check how things went, if you already had the chance to try increasing the variation threshold. Cheers!

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    As you haven’t responded in a while, I’m marking this as resolved. We’ll be here for you if/when you need us.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Variable product help needed.’ is closed to new replies.