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

WC_REST_Customers_V1_Controller::prepare_item_for_response() public WC 1.0

Prepare a single customer output for response.

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

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

WP_REST_Response. $response Response data.

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

$WC_REST_Customers_V1_Controller = new WC_REST_Customers_V1_Controller();
$WC_REST_Customers_V1_Controller->prepare_item_for_response( $user_data, $request );
$user_data(WP_User) (обязательный)
User object.
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Customers_V1_Controller::prepare_item_for_response() WC 4.7.1

<?php
public function prepare_item_for_response( $user_data, $request ) {
	$customer    = new WC_Customer( $user_data->ID );
	$_data       = $customer->get_data();
	$last_order  = wc_get_customer_last_order( $customer->get_id() );
	$format_date = array( 'date_created', 'date_modified' );

	// Format date values.
	foreach ( $format_date as $key ) {
		$_data[ $key ] = $_data[ $key ] ? wc_rest_prepare_date_response( $_data[ $key ] ) : null; // v1 API used UTC.
	}

	$data = array(
		'id'            => $_data['id'],
		'date_created'  => $_data['date_created'],
		'date_modified' => $_data['date_modified'],
		'email'         => $_data['email'],
		'first_name'    => $_data['first_name'],
		'last_name'     => $_data['last_name'],
		'username'      => $_data['username'],
		'last_order'    => array(
			'id'   => is_object( $last_order ) ? $last_order->get_id() : null,
			'date' => is_object( $last_order ) ? wc_rest_prepare_date_response( $last_order->get_date_created() ) : null, // v1 API used UTC.
		),
		'orders_count'  => $customer->get_order_count(),
		'total_spent'   => $customer->get_total_spent(),
		'avatar_url'    => $customer->get_avatar_url(),
		'billing'       => $_data['billing'],
		'shipping'      => $_data['shipping'],
	);

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

	/**
	 * Filter customer data returned from the REST API.
	 *
	 * @param WP_REST_Response $response   The response object.
	 * @param WP_User          $user_data  User object used to create response.
	 * @param WP_REST_Request  $request    Request object.
	 */
	return apply_filters( 'woocommerce_rest_prepare_customer', $response, $user_data, $request );
}