woocommerce_rest_prepare_(post_type)_object хук-фильтрWC 1.0

Filter the data for a response.

The dynamic portion of the hook name, $this->post_type, refers to object type being prepared for the response.

Использование

add_filter( 'woocommerce_rest_prepare_(post_type)_object', 'wp_kama_woocommerce_rest_prepare_post_type_object_filter', 10, 3 );

/**
 * Function for `woocommerce_rest_prepare_(post_type)_object` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param WC_Data          $object   Object data.
 * @param WP_REST_Request  $request  Request object.
 *
 * @return WP_REST_Response
 */
function wp_kama_woocommerce_rest_prepare_post_type_object_filter( $response, $object, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$object(WC_Data)
Object data.
$request(WP_REST_Request)
Request object.

Где вызывается хук

WC_REST_Product_Variations_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Orders_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Product_Variations_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Order_Refunds_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Products_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Coupons_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php 99
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php 509
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php 236
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php 225
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php 190
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-coupons-v2-controller.php 223
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );

Где используется хук в WooCommerce

woocommerce/src/Admin/API/Init.php 49
add_filter( 'woocommerce_rest_prepare_shop_order_object', array( __CLASS__, 'add_currency_symbol_to_order_response' ) );