Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds

Controller::prepare_linksprotectedWC 1.0

Prepare links for the request.

Метод класса: Controller{}

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_links( $item, $request, $response ): array;
$item(разное) (обязательный)
WordPress representation of the item.
$request(WP_REST_Request) (обязательный)
Request object.
$response(WP_REST_Response) (обязательный)
Response object.

Код Controller::prepare_links() WC 10.8.1

protected function prepare_links( $item, WP_REST_Request $request, WP_REST_Response $response ): array {
	$links = array(
		'self'       => array(
			'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $item->get_id() ) ),
		),
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
		),
		'up'         => array(
			'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $item->get_parent_id() ) ),
		),
	);

	if ( $item->get_refunded_by() ) {
		$links['refunded_by'] = array(
			'href'       => rest_url( sprintf( '/wp/v2/users/%d', $item->get_refunded_by() ) ),
			'embeddable' => true,
		);
	}

	return $links;
}