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

WC_REST_Order_Refunds_V2_Controller::prepare_object_for_response() public WC 3.0.0

Prepare a single order output for response.

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

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

WP_Error/WP_REST_Response.

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

$WC_REST_Order_Refunds_V2_Controller = new WC_REST_Order_Refunds_V2_Controller();
$WC_REST_Order_Refunds_V2_Controller->prepare_object_for_response( $object, $request );
$object(WC_Data) (обязательный)
Object data.
$request(WP_REST_Request) (обязательный)
Request object.

Список изменений

С версии 3.0.0 Введена.

Код WC_REST_Order_Refunds_V2_Controller::prepare_object_for_response() WC 4.7.1

<?php
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'] );
	$order               = wc_get_order( (int) $request['order_id'] );

	if ( ! $order ) {
		return new WP_Error( 'woocommerce_rest_invalid_order_id', __( 'Invalid order ID.', 'woocommerce' ), 404 );
	}

	if ( ! $object || $object->get_parent_id() !== $order->get_id() ) {
		return new WP_Error( 'woocommerce_rest_invalid_order_refund_id', __( 'Invalid order refund ID.', 'woocommerce' ), 404 );
	}

	$data    = $this->get_formatted_item_data( $object );
	$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( $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 );
}