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_Products_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_Orders_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_Coupons_V2_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Product_Variations_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
WC_REST_Refunds_Controller::prepare_object_for_response()
woocommerce_rest_prepare_(post_type)_object
woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-products-v2-controller.php 192
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 289
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 561
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 227
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 225
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-variations-controller.php 168
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-refunds-controller.php 113
return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $refund, $request );

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

woocommerce/includes/class-wc-brands.php 70
add_filter( 'woocommerce_rest_prepare_product_object', array( $this, 'rest_api_prepare_brands_to_product' ), 10, 2 ); // WC 3.x.
woocommerce/src/Admin/API/Init.php 51
add_filter( 'woocommerce_rest_prepare_shop_order_object', array( __CLASS__, 'add_currency_symbol_to_order_response' ) );
woocommerce/src/Admin/Features/ProductBlockEditor/Init.php 75
add_filter( 'woocommerce_rest_prepare_product_object', array( $this, 'possibly_add_template_id' ), 10, 2 );
woocommerce/src/Admin/Features/ProductBlockEditor/Init.php 76
add_filter( 'woocommerce_rest_prepare_product_variation_object', array( $this, 'possibly_add_template_id' ), 10, 2 );