WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_REST_Report_Top_Sellers_V1_Controller::prepare_item_for_response() public WC 1.0

Prepare a report sales object for serialization.

{} Это метод класса: WC_REST_Report_Top_Sellers_V1_Controller{}

Хуки из метода
Возвращает

WP_REST_Response. $response Response data.

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

$WC_REST_Report_Top_Sellers_V1_Controller = new WC_REST_Report_Top_Sellers_V1_Controller();
$WC_REST_Report_Top_Sellers_V1_Controller->prepare_item_for_response( $top_seller, $request );
$top_seller(stdClass) (обязательный)
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Report_Top_Sellers_V1_Controller::prepare_item_for_response() WC 4.7.0

<?php
public function prepare_item_for_response( $top_seller, $request ) {
	$data = array(
		'name'       => $top_seller->name,
		'product_id' => $top_seller->product_id,
		'quantity'   => $top_seller->quantity,
	);

	$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
	$data    = $this->add_additional_fields_to_object( $data, $request );
	$data    = $this->filter_response_by_context( $data, $context );

	// Wrap the data in a response object.
	$response = rest_ensure_response( $data );
	$response->add_links( array(
		'about' => array(
			'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ),
		),
		'product' => array(
			'href' => rest_url( sprintf( '/%s/products/%s', $this->namespace, $top_seller->product_id ) ),
		),
	) );

	/**
	 * Filter a report top sellers returned from the API.
	 *
	 * Allows modification of the report top sellers data right before it is returned.
	 *
	 * @param WP_REST_Response $response   The response object.
	 * @param stdClass         $top_seller The original report object.
	 * @param WP_REST_Request  $request    Request used to generate the response.
	 */
	return apply_filters( 'woocommerce_rest_prepare_report_top_sellers', $response, $top_seller, $request );
}