WC_REST_Orders_V2_Controller::prepare_links
Prepare links for the request.
Method of the class: WC_REST_Orders_V2_Controller{}
No Hooks.
Returns
Array. Links for the given post.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_links( $object, $request );
- $object(WC_Data) (required)
- Object data.
- $request(WP_REST_Request) (required)
- Request object.
WC_REST_Orders_V2_Controller::prepare_links() WC REST Orders V2 Controller::prepare links code WC 10.3.6
protected function prepare_links( $object, $request ) {
$links = array(
'self' => array(
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),
),
'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
),
'email_templates' => array(
'href' => rest_url( sprintf( '/%s/%s/%d/actions/email_templates', $this->namespace, $this->rest_base, $object->get_id() ) ),
'embeddable' => true,
),
);
if ( 0 !== (int) $object->get_customer_id() ) {
$links['customer'] = array(
'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object->get_customer_id() ) ),
);
}
if ( 0 !== (int) $object->get_parent_id() ) {
$links['up'] = array(
'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $object->get_parent_id() ) ),
);
}
return $links;
}