WordPress at Your Fingertips
function is not described

WC_Session_Handler::get_customer_unique_id() public WC 5.3.0

Get session unique ID for requests if session is initialized or user ID if logged in. Introduced to help with unit tests.

{} It's a method of the class: WC_Session_Handler{}

No Hooks.

Return

String.

Usage

$WC_Session_Handler = new WC_Session_Handler();
$WC_Session_Handler->get_customer_unique_id();

Changelog

Since 5.3.0 Introduced.

Code of WC_Session_Handler::get_customer_unique_id() WC 5.9.0

public function get_customer_unique_id() {
	$customer_id = '';

	if ( $this->has_session() && $this->_customer_id ) {
		$customer_id = $this->_customer_id;
	} elseif ( is_user_logged_in() ) {
		$customer_id = (string) get_current_user_id();
	}

	return $customer_id;
}