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.
Related Posts:
- Is removing orphaned wp_postmeta records safe?
- WooCommerce – Query for ordered products
- Delete transients in website
- Structure of postmeta meta_value for woocommerce product download
- Cleanup: best way to remove WooCommerce comments from the wp_comments table
- WooCommerce: remove sample & dummy data
- What is table `wp_woocommerce_termmeta` for? [closed]
- Is it fine to have foreign key as primary key?
- Detecting errors generated by $wpdb->get_results()
- wpdb update add current timestamp not working
- Custom form that store input in database
- Restoring WordPress posts from database only
- Displaying content from one WP site on separate WP site
- Lost the `wp_options` table: what’s the best way to restore the site?
- Issue with wp_insert_post and post_content field error Could not update post in the database
- wp_posts – guid update
- Performance Gains of Relational DB Setup
- How to move existing WordPress wp-content folder along with database to new server and new domain name?
- store simple data in get_option()
- How might I retrieve a featured post image from an external WP site and display it as a link back?
- What are conventions about the schema of the $table_prefix
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- BuddyPress: What’s the use of wp_bp_xprofile_data table and how does it get updated? [closed]
- storing database in version control
- Is deleting orphaned wp_options entries safe?
- How to build a movie database with wordpress?
- What’s the most efficient database method to add and query usermeta?
- How to solve slow WordPress site caused by attachment_metadata
- Sub-domain or 2nd, temporary different domain?
- Where is custom template file chosen for a post stored in the DB?
- How do i get user data from a custom table in the wordpress database by user ID?
- Converting WordPress into Android or iPhone app
- Safe way to find last inserted id in a table?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Database slowdown after update to 3.4.1
- WooCommerce sku location in DB
- How to insert data into MySQL database from the form created in WordPress site
- Emoji support and MariaDB 10.0.30-
- WordPress DATABASE Update Manually?
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- Can I have multiple database users within WordPress?
- How do I copy a wordpress database?
- Export all content from wordpress
- Modify Database in Multi-Site wp_usermeta table
- Form Data not getting stored in WordPress database
- Hook directly into query execution
- $wpdb doesn’t like to store arrays
- Connect to a remote database for wordpress in my own hosting server
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- WordPress ‘repairing database’ in a constant error loop?
- What Is the Proper Way to Merge Usermeta Table to a an existing WP Database?
- Importing CSV into database table not working?
- “Database Connection Error” upon install in Apache VirtualHost document root.. Why did this happen? [closed]
- Check if an option exists and get its value in one hit
- Change options table prefix only
- Problems with moving my WordPress site to another domain/server
- Is it important to have integers inserted using %d rather than %s?
- Export a custom Mysql database product catalog to WordPress
- Is it safe to have 2 mysql users?
- Any risk to changing WP table col CHARACTER_MAXIMUM_LENGTH?
- Global__r connection timed out
- Connect to database in the header of my WordPress website
- Should I store critical css in the database or in my theme’s filesystem?
- WordPress url transformation script
- Moving WordPress site to new domain – database import [duplicate]
- Location of WP default mySQL tables creation file?
- Disable Database Update Required ? break my website
- Get results from wordpress data custom table
- Outputting query results
- Help With a Large WordPress Based MySQL Database on Shared Hosting
- WordPress where clauses in db select
- How to display data from db in select list [closed]
- Will adding & modifying default WordPress table index break future WordPress update
- Database migration issues – Error #1046 No database selected
- echo site_url() returns a different value than what is in the database siteurl field
- Search Character Set Problem
- Native timestamp on wp_options option
- SELECT rows between two datetimes when the range is dynamic [closed]
- How to get the full stack trace for WordPress “table doesn’t exist” error in debug.log?
- How to fix Uploaded to this post option to see group of images uploaded to a post?
- How to access a table in a wordpress database using REST API?
- error establishing a database connection 3
- Correct and secure way to access a custom SQL database in a custom PHP template file
- Does WordPress Support Using Named Pipes on the Windows Operating System?
- Missing latest posts and options after DB migration via phpMyAdmin
- get_the_terms is not working
- Custom metabox does not store data
- wordpress database error
- How do i get value from wp_postmeta?
- Local host to server import problem
- Restoring .sql backup results in “Error establishing a database connection”
- Link to handle $_GET request
- WordPress sync with phpbb
- “MySQL server has gone away” since update to 3.8
- featured image not showing up with mysql_connect
- Getting deleted users in database
- Options of accessing wordpress data from mobile app
- Getting data from a table using a query
- Database interaction (private-public) [closed]
- WP Multisite Users Not Linking