WC_API_Webhooks::get_webhook_delivery() public WC 2.2
Deprecated from version 3.3.0. It is no longer supported and can be removed in future releases. Use
s logging system
instead.╳Get the delivery log for the given webhook ID and delivery ID
{} It's a method of the class: WC_API_Webhooks{}
Hooks from the method
Return
Array|WP_Error.
Usage
$WC_API_Webhooks = new WC_API_Webhooks(); $WC_API_Webhooks->get_webhook_delivery( $webhook_id, $id, $fields );
- $webhook_id(string) (required)
- webhook ID
- $id(string) (required)
- delivery log ID
- $fields(string|null)
- fields to limit response to
Changelog
Since 2.2 | Introduced. | |
Deprecated Since 3.3.0 | Webhooks deliveries logs now uses logging system. |
Code of WC_API_Webhooks::get_webhook_delivery() WC API Webhooks::get webhook delivery WC 5.0.0
public function get_webhook_delivery( $webhook_id, $id, $fields = null ) {
try {
// Validate webhook ID
$webhook_id = $this->validate_request( $webhook_id, 'shop_webhook', 'read' );
if ( is_wp_error( $webhook_id ) ) {
return $webhook_id;
}
$id = absint( $id );
if ( empty( $id ) ) {
throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery ID.', 'woocommerce' ), 404 );
}
$webhook = new WC_Webhook( $webhook_id );
$log = 0;
if ( ! $log ) {
throw new WC_API_Exception( 'woocommerce_api_invalid_webhook_delivery_id', __( 'Invalid webhook delivery.', 'woocommerce' ), 400 );
}
return array( 'webhook_delivery' => apply_filters( 'woocommerce_api_webhook_delivery_response', array(), $id, $fields, $log, $webhook_id, $this ) );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
}