Customers report endpoint: only include customer link if they’re a registered user.

This commit is contained in:
Jeff Stieler 2018-12-20 09:46:29 -07:00
parent fc20d2bb1b
commit dd87522a5e
1 changed files with 6 additions and 5 deletions

View File

@ -141,14 +141,15 @@ class WC_Admin_REST_Reports_Customers_Controller extends WC_REST_Reports_Control
* @return array * @return array
*/ */
protected function prepare_links( $object ) { protected function prepare_links( $object ) {
$links = array( if ( empty( $object['user_id'] ) ) {
return array();
}
return array(
'customer' => array( 'customer' => array(
// TODO: is this meant to be a core WC link? 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object['user_id'] ) ),
'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $object['customer_id'] ) ),
), ),
// TODO: add user link?
); );
return $links;
} }
/** /**