Woocommerce get variations API does not always return newly created variations

Viewed 186

On woocommerce, I add a new variation to a product. I have a hook configured for product.updated to my API.

Once the hook is received on my API for the updated product, I do a get variations API call hoping to get a list including the newly added variation.

Sometimes, the response includes the newly added variations. Other times, it does not.

The same thing happens with updating variations. If I update the regular_price and publish the changes, product.updated hook fires to my API. When I do get variations again, that variation in the response still has the former price.

I realized that if I call get variations like 1 or 2 mins after product.updated hook was fired, I will receive all variations including updates in the response.


What could be going on in woocommerce?
Does woocommerce generate an id for a variation and trigers a hook before taking time to build the object? This might explain why it works after a while.
Any other ideas?

  • I'm using Automattic\WooCommerce\Client lib.
  • woocommerce REST v3
  • woocommere v3.9.2
0 Answers
Related