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

WC_REST_Taxes_V1_Controller::prepare_item_for_response() WC 1.0

Prepare a single tax output for response.

Это метод класса: WC_REST_Taxes_V1_Controller

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

WP_REST_Response. $response Response data.

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

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

Код WC REST Taxes V1 Controller::prepare item for response: woocommerce/includes/api/v1/class-wc-rest-taxes-controller.php WC 3.6.3

<?php
public function prepare_item_for_response( $tax, $request ) {
	global $wpdb;

	$id   = (int) $tax->tax_rate_id;
	$data = array(
		'id'       => $id,
		'country'  => $tax->tax_rate_country,
		'state'    => $tax->tax_rate_state,
		'postcode' => '',
		'city'     => '',
		'rate'     => $tax->tax_rate,
		'name'     => $tax->tax_rate_name,
		'priority' => (int) $tax->tax_rate_priority,
		'compound' => (bool) $tax->tax_rate_compound,
		'shipping' => (bool) $tax->tax_rate_shipping,
		'order'    => (int) $tax->tax_rate_order,
		'class'    => $tax->tax_rate_class ? $tax->tax_rate_class : 'standard',
	);

	// Get locales from a tax rate.
	$locales = $wpdb->get_results( $wpdb->prepare( "
		SELECT location_code, location_type
		FROM {$wpdb->prefix}woocommerce_tax_rate_locations
		WHERE tax_rate_id = %d
	", $id ) );

	if ( ! is_wp_error( $tax ) && ! is_null( $tax ) ) {
		foreach ( $locales as $locale ) {
			$data[ $locale->location_type ] = $locale->location_code;
		}
	}

	$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( $this->prepare_links( $tax ) );

	/**
	 * Filter tax object returned from the REST API.
	 *
	 * @param WP_REST_Response $response The response object.
	 * @param stdClass         $tax      Tax object used to create response.
	 * @param WP_REST_Request  $request  Request object.
	 */
	return apply_filters( 'woocommerce_rest_prepare_tax', $response, $tax, $request );
}