WC_REST_Customer_Downloads_V1_Controller::prepare_links
Prepare links for the request.
Method of the class: WC_REST_Customer_Downloads_V1_Controller{}
No Hooks.
Returns
Array. Links for the given customer download.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_links( $download, $request );
- $download(stdClass) (required)
- Download object.
- $request(WP_REST_Request) (required)
- Request object.
WC_REST_Customer_Downloads_V1_Controller::prepare_links() WC REST Customer Downloads V1 Controller::prepare links code WC 10.6.2
protected function prepare_links( $download, $request ) {
$base = str_replace( '(?P<customer_id>[\d]+)', $request['customer_id'], $this->rest_base );
$links = array(
'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ),
),
'product' => array(
'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $download->product_id ) ),
),
'order' => array(
'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $download->order_id ) ),
),
);
return $links;
}