Woocommerce – Check product stock availability from external database

Your approach is impractical in any site with decent traffic. In that case having real time updates from a DB is the best way to bring your site down. What you need is to check the availability when people at items to carts and then again before the actual checkout.

In addition you can update the current number of items every hour (or faster if you really want to try to be as accurate as possible) with a wordpress cron task, but this number is just to give the user a feeling if he should hurry and buy or he has time to think about it. Just remember that unless you are going to keep some ajax going to update the number, the user will very likely see a stale information as the kids called him (or any other distraction) and he returned only after half an hour later to look at the product.