Automattic\WooCommerce\StoreApi

Authentication::maybe_use_store_api_session_handlerpublicWC 10.6.0

Use the Store API session handler when a valid Cart-Token is present.

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

Хуков нет.

Возвращает

Строку.

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

$Authentication = new Authentication();
$Authentication->maybe_use_store_api_session_handler( $handler ): string;
$handler(строка) (обязательный)
Session handler class name.

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

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

Код Authentication::maybe_use_store_api_session_handler() WC 11.0.1

public function maybe_use_store_api_session_handler( $handler ): string {
	if ( ! WC()->is_store_api_request() && ! $this->has_store_api_route_as_get_parameter() ) {
		return $handler;
	}

	$cart_token = CartTokenUtils::get_request_cart_token();
	if ( $cart_token && CartTokenUtils::validate_cart_token( $cart_token ) ) {
		return SessionHandler::class;
	}
	return $handler;
}