WC_REST_Orders_V1_Controller::prepare_links()protectedWC 1.0

Prepare links for the request.

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

Хуков нет.

Возвращает

Массив. Links for the given order.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_links( $order, $request );
$order(WC_Order) (обязательный)
Order object.
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Orders_V1_Controller::prepare_links() WC 8.7.0

protected function prepare_links( $order, $request ) {
	$links = array(
		'self' => array(
			'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id() ) ),
		),
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
		),
	);
	if ( 0 !== (int) $order->get_user_id() ) {
		$links['customer'] = array(
			'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $order->get_user_id() ) ),
		);
	}
	if ( 0 !== (int) $order->get_parent_id() ) {
		$links['up'] = array(
			'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $order->get_parent_id() ) ),
		);
	}
	return $links;
}