Automattic\WooCommerce\StoreApi\Routes\V1

AbstractCartRoute::add_response_headers()protectedWC 1.0

Add nonce headers to a response object.

Method of the class: AbstractCartRoute{}

No Hooks.

Return

\WP_REST_Response.

Usage

// protected - for code of main (parent) or child class
$result = $this->add_response_headers( $response );
$response(\WP_REST_Response) (required)
The response object.

AbstractCartRoute::add_response_headers() code WC 9.3.3

protected function add_response_headers( \WP_REST_Response $response ) {
	$nonce = wp_create_nonce( 'wc_store_api' );

	$response->header( 'Nonce', $nonce );
	$response->header( 'Nonce-Timestamp', time() );
	$response->header( 'User-ID', get_current_user_id() );
	$response->header( 'Cart-Token', $this->get_cart_token() );

	return $response;
}