WooCommerce has a feature for simple products called the Stock status. This has known issues once you have variable products. This is a good explanation of what is happening for stores trying to use this. The short answer is don't.

The In stock and out of stock setting does not mean much once you actually manage inventory, TranslatorHQ does not change this setting.we only set the stock values through the API. For variable products this is looking at the first product variations stock levels only. and hence the issue appearing. the bug in the way it sets this is well known but not addressed.


https://github.com/woocommerce/woocommerce/issues/16620 

Here is a solution but this is not considered a bug by the WooCommerce team as it works as they think is ok. 


But first...

Diagnosis of the problem

The problem occurs when the actions below happen in this exact order:

  1. A simple product is created
  2. The product has "manage stock" option enabled
  3. The product has a stock quantity greater than 0
  4. The product is later changed to variable product
  5. The variable product has separate stock value for each variant
  6. Option "manage stock at product level" is still enabled when people purchase products

Why the problem occurs

Let's start from the begining.

Technically, when product options in the product's edit page are changed, some fields in the product settings get hidden and other show up. The important thing to remember is that hiding a field doesn't mean that the data is removed from the database (in most cases) and so some functions that use this data still work.

Now, when a single product doesn't have the manage stock option enabled, a store manager can set "stock status" to "in stock", "out of stock" or "available on backorder". Now, when the manager enables "manage stock", the field with stock status gets hidden, but it doesn't stop holding a value and the connected functions don't stop working.

In other words when a single product has the "manage stock at product level" enabled and someone purchases a product, than 1 is removed from stock quantity field and when this number reaches 0 the invisible field "stock status" is set up to "Out of Stock".

But it doesn't cause a problem because when the manager increases the stock quantity, the "Out of stock" is changed back to "in stock".

The problem is that it doesnt happen with variable products. But I will get to it later.

So far we have our single product and everything works. When we try turning on and off "manage stock" option, we toggle the visibility of the "Stock status" field.

The problem starts when the product is changed to variable.

In this case toggling the section "manage stock" (in the inventory tab) doesn't show the "stock status" field. If it did then diagnosing the problem would be so much easier, because this particular field holds the stock status that is displayed in category pages in store!

How do I know?

Because fortunately, there is a way to view what value this field holds - in the "quick edit" panel of the product list.

If you uncheck there "manage stock" than you will see the stock status. And this is exactly the same statusthat is shown in category pages and in "all products" list in the admin panel.

And this value is the problem (and the fact that it cannot be manually updated - try it if you like)

How to check if the problem will happen to you in the future and prevent it from happening

The quickest way to check if a problem will happen to you is to look at the "Stock status" column in "All products" admin page.

When next to a variable product you see stock status and stock quantity, than there is a big chance that this product will have problems in the future. If you find one like that, edit the product and see if it manages stock at product level or variable level. If in both of them, than disable the product level stock management and update the product. You should be safe now.

How to remove the "out of stock" label from variable products that are in stock

First of all I will tell you what doesn't work.

If you try to manually change the "stock status" in quick edit panel, you will fail. It won't update.

Solution 1

You have to:

  1. Duplicate the product you are having problems with. Please notice that the clone will have a proper stock status!
  2. Copy the URL of the original product
  3. Remove the original product
  4. Uncheck in the cloned copy "manage stock at product level"
  5. Remove the "-copy" suffix from the URL and from the title of the clone
  6. Publish the cloned product

If you did everything correctly, the new product should have exactly the same URL as the previous one and should give you no trouble in the future.

Solution 2

This solution involves deleting and recreating variable products so it is only useful when you don't have many and/or when the ID of the product needs to remain the same.

  1. Change product type to "simple"
  2. Switch off "manage product options at product level" (in the Inventory tab)
  3. Update product
  4. Change product type back to "variable"
  5. Recreate the variable products
And - obviously - don't enable both "manage product at product level" and "manage product at variable level" options