WooCommerce Product Unavailable Out of Stock Problem

Home/WooCommerce Product Unavailable Out of Stock Problem

Recently, a client was reporting that they were seeing an out of stock message on their product page, which wasn’t correct.  All of the settings and product variations were correct and in stock, but the message persisted.

It wasn’t on all products, but just a few select variable products where it displayed:

This product is currently out of stock and unavailable

Obviously this was frustrating, but after a little investigation, the fact that they were variations was the key to fixing the problem.

Typically WooCommerce allows 60 product variations in total when using ajax to update the variations on the product page, and in most cases the error message is due to the product exceeding this. Fortunately, there’s a relatively simple fix.

Add the following code to the functions.php of your theme or child theme and you should be seeing your products back in stock in no time at all.

// Increase WooCommerce Variation Limit
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 100;
}

add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 100, 2 );
2017-05-19T15:48:04+00:00 November 8th, 2016|Web Programming, WordPress Snippets|4 Comments

About the Author:

Warren Chandler is a freelance web programmer and web developer, based in Frinton on Sea, Essex. Warren specialises in web programming, web design, corporate identity, copy writing, SEO, logo and print media for home, work, and mobile platforms.

4 Comments

  1. Irfan Saleem February 22, 2017 at 1:45 pm - Reply

    Thanks, Warren. Worked perfectly.

  2. Arsh February 28, 2017 at 2:20 pm - Reply

    Thanks Buddy.

  3. jorge March 13, 2017 at 4:38 am - Reply

    Wich functions.php? there are a lot, could you be more specific, thank you 🙂

  4. Warren Chandler April 5, 2017 at 3:44 pm - Reply

    The functions.php you need is the one from your theme, or child theme. Sorry for any confusion.

Leave A Comment