Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Webhook::get_wp_api_payload( string $resource, int $resource_id, string $event )
Get WP API integration payload.
Description Description
Parameters Parameters
- $resource
-
(Required) Resource type.
- $resource_id
-
(Required) Resource ID.
- $event
-
(Required) Event type.
Return Return
(array)
Source Source
File: includes/class-wc-webhook.php
private function get_wp_api_payload( $resource, $resource_id, $event ) { switch ( $resource ) { case 'coupon': case 'customer': case 'order': case 'product': // Bulk and quick edit action hooks return a product object instead of an ID. if ( 'product' === $resource && 'updated' === $event && is_a( $resource_id, 'WC_Product' ) ) { $resource_id = $resource_id->get_id(); } $version = str_replace( 'wp_api_', '', $this->get_api_version() ); $payload = wc()->api->get_endpoint_data( "/wc/{$version}/{$resource}s/{$resource_id}" ); break; // Custom topics include the first hook argument. case 'action': $payload = array( 'action' => current( $this->get_hooks() ), 'arg' => $resource_id, ); break; default: $payload = array(); break; } return $payload; }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |