woocommerce_rest_prepare_product_attribute
Filter a attribute item returned from the API.
Allows modification of the product attribute data right before it is returned.
Использование
add_filter( 'woocommerce_rest_prepare_product_attribute', 'wp_kama_woocommerce_rest_prepare_product_attribute_filter', 10, 3 );
/**
* Function for `woocommerce_rest_prepare_product_attribute` filter-hook.
*
* @param WP_REST_Response $response The response object.
* @param object $item The original attribute object.
* @param WP_REST_Request $request Request used to generate the response.
*
* @return WP_REST_Response
*/
function wp_kama_woocommerce_rest_prepare_product_attribute_filter( $response, $item, $request ){
// filter...
return $response;
}
- $response(WP_REST_Response)
- The response object.
- $item(объект)
- The original attribute object.
- $request(WP_REST_Request)
- Request used to generate the response.
Где вызывается хук
woocommerce_rest_prepare_product_attribute
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-attributes-v1-controller.php 452
return apply_filters( 'woocommerce_rest_prepare_product_attribute', $response, $item, $request );