I’ve recently been working on a project which synced data between WooCommerce and an internal warehouse system, I was utilising the WooCommerce webhooks to achieve near real time syncing between the two systems, without having the creating API scripts to poll for data on a regular basis.
The Problem?
There was a delay ranging from couple seconds to 1 minute, WooCommerce uses a system called actions scheduler, this is an improved wordpress cron, allowing background processing to occur within WordPress for single or recurring actions. This is great and what WooCommerce utilises for its web hook system, however it is backed by the word press cron and the next load of scheduled actions will run on the next cron run (every 1 minute).
For this project, I needed the web hooks to fire as soon as the button was clicked, and a possible delay up to 1 minute was to long.
Fix
Disable async web hooks, web hooks will not fire as soon as they are created as part of the browser request.
| 1 2 3 4 5 6 7 | /*  * WooCommerce Disable async webhook delivery  */ function custom_woocommerce_disable_async_webhook() {     return false; } add_filter(‘woocommerce_webhook_deliver_async’, ‘custom_woocommerce_disable_async_webhook’); | 
I would recommend you test your site after doing this change, for example order webhooks will fire when a customer creates a new order, which could lead to a slow user experience.
Leave a Reply