• Resolved oringeverything

    (@oringeverything)


    Firstly, I hope everyone is OK and dealing with various states of lock-down. I’m in the UK and in the 2nd week of staying at home. To help stave off the boredom I’m trying to build a simple website at o-ring-everything.com.

    My issues are 2-fold:

    1. I inputted the first product, which has 100 variations (FX airguns). It took ages and it doesn’t work. When selecting a variation which exists (**see 2.) eg. Biathlon, All Models, Full Kit, All Calibres it returns “Sorry, this product is unavailable. Please choose a different combination.”. I tested this with many available variations which are in stock and have prices, but it still returns the same error.

    Just to make sure I wasn’t doing anything wrong I added another product, albeit with fewer variations, (Gamo) and this works fine.

    I have seen many threads with code to fix this but none of these “fixes” seem to work.

    2. The other issue is all the attribute combinations are available to select, even though I have not created a variation for it. With issue 1. fixed i will still have a problem with customers being able to choose a variation which is not for sale, which will be confusing.

    In eBay only available options are clickable (and visible) which makes the selection process easier.

    I don’t think I’m trying to do anything too complicated, but any help much appreciated.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ordinarily, WooCommerce uses an AJAX call to set the available variations when you select a variation on which subsequent ones are dependent. For example, when you select the Model on your sample page, WooCommerce sends an AJAX call to the server to populate the Sub-model with the correct options. However, if you exceed the default 30 variations, WooCommerce doesn’t use AJAX, and you end up with options that don’t exist in the drop-down boxes, and your customers see the confusing “Sorry, this product is unavailable. Please choose a different combination.”

    The fix for that issue is to increase the default number of variations that are allowed to generate an AJAX call. To do that, figure out what your maximum number of variations will be, and add the following code snippet to your child theme’s functions.php:

    
    add_filter( 'woocommerce_ajax_variation_threshold', 'wc_ajax_variation_threshold' );
    	function wc_ajax_variation_threshold() {
    	    return 150;
    	}
    

    Change the “150” in the snippet to something higher than your maximum number of variations.

    Keep in mind that WooCommerce added the default of 30 to reduce the load on your server. If your server is underpowered and the threshold is set too high, you can end up with problems.

    Give that a try and see if it fixes both issue #1 and issue #2.

    Thread Starter oringeverything

    (@oringeverything)

    Hello @linux4me2

    I am certain I tried this before.
    Edited the file just now and it’s working like a dream – Many thanks for your help.

    Regards, Matt

    Hi @oringeverything

    You’re welcome! I’m glad you got it working.

    Plugin Support con

    (@conschneider)

    Engineer

    Thanks everyone.
    Closing.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WooCommerce error’ is closed to new replies.