wc_webhook_process_delivery( WC_Webhook $webhook, array $arg )
Process webhook delivery.
Description Description
Parameters Parameters
- $webhook
-
(Required) Webhook instance.
- $arg
-
(Required) Delivery arguments.
Source Source
File: includes/wc-webhook-functions.php
function wc_webhook_process_delivery( $webhook, $arg ) {
// Webhooks are processed in the background by default
// so as to avoid delays or failures in delivery from affecting the
// user who triggered it.
if ( apply_filters( 'woocommerce_webhook_deliver_async', true, $webhook, $arg ) ) {
$queue_args = array(
'webhook_id' => $webhook->get_id(),
'arg' => $arg,
);
$next_scheduled_date = WC()->queue()->get_next( 'woocommerce_deliver_webhook_async', $queue_args, 'woocommerce-webhooks' );
// Make webhooks unique - only schedule one webhook every 10 minutes to maintain backward compatibility with WP Cron behaviour seen in WC < 3.5.0.
if ( is_null( $next_scheduled_date ) || $next_scheduled_date->getTimestamp() >= ( 600 + gmdate( 'U' ) ) ) {
WC()->queue()->add( 'woocommerce_deliver_webhook_async', $queue_args, 'woocommerce-webhooks' );
}
} else {
// Deliver immediately.
$webhook->deliver( $arg );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |