Automattic\WooCommerce\StoreApi

SessionHandler::generate_customer_idpublicWC 1.0

Generate a unique customer ID for guests, or return user ID if logged in.

Method of the class: SessionHandler{}

No Hooks.

Returns

String.

Usage

$SessionHandler = new SessionHandler();
$SessionHandler->generate_customer_id();

SessionHandler::generate_customer_id() code WC 10.7.0

public function generate_customer_id() {
	return is_user_logged_in() ? (string) get_current_user_id() : wc_rand_hash( 't_', 30 );
}