Automattic\WooCommerce\StoreApi\Routes\V1\Agentic
CheckoutSessionsUpdate::has_cart_token
Use the checkout_session_id as Cart-Token, and set the respective values to HTTP header and request.
Method of the class: CheckoutSessionsUpdate{}
No Hooks.
Returns
true|false|null.
Usage
// protected - for code of main (parent) or child class $result = $this->has_cart_token( $request );
- $request(WP_REST_Request) (required)
- Request object.
CheckoutSessionsUpdate::has_cart_token() CheckoutSessionsUpdate::has cart token code WC 10.8.1
protected function has_cart_token( \WP_REST_Request $request ) {
$session_id = $request->get_param( 'checkout_session_id' );
if ( is_null( $this->has_cart_token ) ) {
$this->has_cart_token = CartTokenUtils::validate_cart_token( $session_id );
}
// This allows the session will be loaded later without any further intervention.
if ( true === $this->has_cart_token ) {
$request->set_header( 'Cart-Token', $session_id );
$_SERVER['HTTP_CART_TOKEN'] = $session_id;
}
return $this->has_cart_token;
}