WordPress at Your Fingertips
function is not described

WC_REST_Orders_V2_Controller::prepare_object_for_response() public WC 3.0.0

Prepare a single order output for response.

{} It's a method of the class: WC_REST_Orders_V2_Controller{}

Return

WP_REST_Response.

Usage

$WC_REST_Orders_V2_Controller = new WC_REST_Orders_V2_Controller();
$WC_REST_Orders_V2_Controller->prepare_object_for_response( $object, $request );
$object(WC_Data) (required)
Object data.
$request(WP_REST_Request) (required)
Request object.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Orders_V2_Controller::prepare_object_for_response() WC 5.9.0

public function prepare_object_for_response( $object, $request ) {
	$this->request       = $request;
	$this->request['dp'] = is_null( $this->request['dp'] ) ? wc_get_price_decimals() : absint( $this->request['dp'] );
	$request['context']  = ! empty( $request['context'] ) ? $request['context'] : 'view';
	$data                = $this->get_formatted_item_data( $object );
	$data                = $this->add_additional_fields_to_object( $data, $request );
	$data                = $this->filter_response_by_context( $data, $request['context'] );
	$response            = rest_ensure_response( $data );
	$response->add_links( $this->prepare_links( $object, $request ) );

	/**
	 * 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.
	 *
	 * @param WP_REST_Response $response The response object.
	 * @param WC_Data          $object   Object data.
	 * @param WP_REST_Request  $request  Request object.
	 */
	return apply_filters( "woocommerce_rest_prepare_{$this->post_type}_object", $response, $object, $request );
}