WC_Session_Handler::get_customer_unique_id
Get session unique ID for requests if session is initialized or user ID if logged in. Introduced to help with unit tests.
Method of the class: WC_Session_Handler{}
No Hooks.
Returns
String.
Usage
$WC_Session_Handler = new WC_Session_Handler(); $WC_Session_Handler->get_customer_unique_id();
Changelog
| Since 5.3.0 | Introduced. |
WC_Session_Handler::get_customer_unique_id() WC Session Handler::get customer unique id code WC 10.3.3
public function get_customer_unique_id() {
$customer_id = '';
if ( $this->has_session() && $this->get_customer_id() ) {
$customer_id = $this->get_customer_id();
} elseif ( is_user_logged_in() ) {
$customer_id = (string) get_current_user_id();
}
return $customer_id;
}