WC_Session_Handler::get_customer_unique_id()publicWC 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.

Метод класса: WC_Session_Handler{}

Хуков нет.

Возвращает

Строку.

Использование

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

Список изменений

С версии 5.3.0 Введена.

Код WC_Session_Handler::get_customer_unique_id() WC 8.7.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;
}