Automattic\WooCommerce\StoreApi\Routes\V1
Products::prepare_links
Prepare links for the request.
Method of the class: Products{}
No Hooks.
Returns
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_links( $item, $request );
- $item(WC_Product) (required)
- Product object.
- $request(WP_REST_Request) (required)
- Request object.
Products::prepare_links() Products::prepare links code WC 9.9.3
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; }