Automattic\WooCommerce\StoreApi

Authentication::get_cart_tokenprotectedWC 1.0

Gets the cart token from the request header.

Method of the class: Authentication{}

No Hooks.

Returns

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_cart_token( $request );
$request(WP_REST_Request) (required)
The REST request instance.

Authentication::get_cart_token() code WC 9.8.5

protected function get_cart_token( \WP_REST_Request $request ) {
	return wc_clean( wp_unslash( $request->get_header( 'Cart-Token' ) ?? '' ) );
}