WooCommerce fix slow or delayed webhooks and achieve instant webhook firing

Ive 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 two systems.

I noticed there was a delay ranging from couple seconds to 1 minute, after some research I believe by default WooCommerce queues webhooks and fires on the next WordPress cron run, hence why it could take up to a full minute before the hooks fired.

Problem

Web hooks are queued by default and fired async on the next cron schedule. Causing delays of up to 1 minute.

Solution

Disable async web hooks, meaning they fire as soon as the event creating them fires.

/*
 * WooCommerce Disable async webhook delivery
 */
function custom_woocommerce_disable_async_webhook() {
	return False;
}
add_filter('woocommerce_webhook_deliver_async', 'custom_woocommerce_disable_async_webhook');

Notes

I would recommend you test your site after doing this change, it could cause slow downs based on how your using your site, for example order webhooks will fire when a customer creates a new order.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments

    • Hi, you can either create a plugin or simply add this to your themes function.php file. But the change will then be theme specific.