WC_API_Webhooks::get_webhook( int $id, array $fields = null )
Get the webhook for the given ID
Description Description
Parameters Parameters
- $id
-
(Required) webhook ID
- $fields
-
(Optional)
Default value: null
Return Return
(array|WP_Error)
Source Source
File: includes/legacy/api/v2/class-wc-api-webhooks.php
public function get_webhook( $id, $fields = null ) { // ensure webhook ID is valid & user has permission to read $id = $this->validate_request( $id, 'shop_webhook', 'read' ); if ( is_wp_error( $id ) ) { return $id; } $webhook = wc_get_webhook( $id ); $webhook_data = array( 'id' => $webhook->get_id(), 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'created_at' => $this->server->format_datetime( $webhook->get_date_created() ? $webhook->get_date_created()->getTimestamp() : 0, false, false ), // API gives UTC times. 'updated_at' => $this->server->format_datetime( $webhook->get_date_modified() ? $webhook->get_date_modified()->getTimestamp() : 0, false, false ), // API gives UTC times. ); return array( 'webhook' => apply_filters( 'woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this ) ); }
Changelog Changelog
Version | Description |
---|---|
2.2 | Introduced. |