[2.2] get_user and get_user_id methods

Closes #5429
This commit is contained in:
Mike Jolley 2014-05-07 15:11:34 +01:00
parent 83f1236875
commit 3670afdffb
1 changed files with 18 additions and 0 deletions

View File

@ -115,6 +115,24 @@ class WC_Order {
return $value;
}
/**
* Gets the user ID associated with the order. Guests are 0.
* @since 2.2
* @return int|false
*/
public function get_user_id() {
return $this->customer_user ? $this->customer_user : 0;
}
/**
* Get the user associated with the order. False for guests.
* @since 2.2
* @return WP_User|false
*/
public function get_user() {
return $user_id = $this->get_user_id() ? get_user_by( 'id', $user_id ) : false;
}
/**
* Check if an order key is valid.
*