Automattic\WooCommerce\StoreApi
Authentication::maybe_use_store_api_session_handler
Use the Store API session handler when a valid Cart-Token is present.
Method of the class: Authentication{}
No Hooks.
Returns
string.
Usage
$Authentication = new Authentication(); $Authentication->maybe_use_store_api_session_handler( $handler ): string;
- $handler(string) (required)
- Session handler class name.
Changelog
| Since 10.6.0 | Introduced. |
Authentication::maybe_use_store_api_session_handler() Authentication::maybe use store api session handler code 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;
}