woocommerce_hydration_request_after_callbacks
Similar to WP core's rest_request_after_callbacks this allows to modify the response after it has been generated. Allows backward compatibility with the rest_request_after_callbacks by providing the same arguments.
Usage
add_filter( 'woocommerce_hydration_request_after_callbacks', 'wp_kama_woocommerce_hydration_request_after_callbacks_filter', 10, 3 ); /** * Function for `woocommerce_hydration_request_after_callbacks` filter-hook. * * @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. Usually a WP_REST_Response or WP_Error. * @param array $handler Route handler used for the request. * @param WP_REST_Request $request Request used to generate the response. * * @return WP_REST_Response|WP_HTTP_Response|WP_Error|mixed */ function wp_kama_woocommerce_hydration_request_after_callbacks_filter( $response, $handler, $request ){ // filter... return $response; }
- $response(WP_REST_Response|WP_HTTP_Response|WP_Error|mixed)
- Result to send to the client. Usually a WP_REST_Response or WP_Error.
- $handler(array)
- Route handler used for the request.
- $request(WP_REST_Request)
- Request used to generate the response.
Changelog
Since 8.9.0 | Introduced. |
Where the hook is called
woocommerce_hydration_request_after_callbacks
woocommerce/src/Blocks/Domain/Services/Hydration.php 169
$response = apply_filters( 'woocommerce_hydration_request_after_callbacks', $response, $handler, $request );