WC_REST_Products_V1_Controller::prepare_links()protectedWC 1.0

Prepare links for the request.

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

Хуков нет.

Возвращает

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

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

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

Код WC_REST_Products_V1_Controller::prepare_links() WC 8.7.0

protected function prepare_links( $product, $request ) {
	$links = array(
		'self' => array(
			'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $product->get_id() ) ),
		),
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
		),
	);

	if ( $product->get_parent_id() ) {
		$links['up'] = array(
			'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $product->get_parent_id() ) ),
		);
	}

	return $links;
}