@rjriso
I have looked at the async filter solution, but when I employ that, I get incomplete order objects.
Do you mean using the woocommerce_webhook_deliver_async
filter? If so, I can understand why there would be incomplete order objects as they probably haven’t saved to the database yet.
I have webhooks that sometimes don’t fire for 20-90 minutes after an order is created. The order acknowledgement and notification emails fire immediately. Can’t we do the same with webhooks?
Processing webhooks could cause delays elsewhere. Like if an order is being created and a webhook is fired and the receiving site is slow, it could slow processing of the order, which results in a bad user experience.
The wc_webhook_process_delivery
function is what is called to create the webhook actions. This function is defined and hooked here:
https://github.com/woocommerce/woocommerce/blob/4.3.1/includes/wc-webhook-functions.php#L18-L40
When a webhook action happens, it schedules the webhook to be fired off via Action Scheduler. Action Scheduler should run once a minute as long as someone is logged into the admin, but if no one is logged in it is going to rely upon traffic to the site. This may be the reason why you see delays with the webhooks being delivered.
Pending scheduled actions can be seen under WooCommerce > Status > Scheduled Actions > Pending.
Alternatively can webhook processing be tied to a custom chron job?
This might be possible, but shouldn’t be needed. If you want to create a server based cron to run the action_scheduler_run_queue
WP Cron event once a minute, that should suffice to get all scheduled actions running on time.