Automattic\WooCommerce\StoreApi\Routes\V1
Products::prepare_links
Prepare links for the request.
Метод класса: Products{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->prepare_links( $item, $request );
- $item(WC_Product) (обязательный)
- Product object.
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Products::prepare_links() Products::prepare links WC 10.3.6
protected function prepare_links( $item, $request ) {
$links = array(
'self' => array(
'href' => rest_url( $this->get_namespace() . $this->get_path() . '/' . $item->get_id() ),
),
'collection' => array(
'href' => rest_url( $this->get_namespace() . $this->get_path() ),
),
);
if ( $item->get_parent_id() ) {
$links['up'] = array(
'href' => rest_url( $this->get_namespace() . $this->get_path() . '/' . $item->get_parent_id() ),
);
}
return $links;
}