Automattic\WooCommerce\StoreApi\Routes\V1

AbstractCartRoute::add_response_headersprotectedWC 1.0

Add nonce headers to a response object.

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

Хуков нет.

Возвращает

\WP_REST_Response.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->add_response_headers( $response );
$response(WP_REST_Response) (обязательный)
The response object.

Код AbstractCartRoute::add_response_headers() WC 10.0.2

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() );
	$response->header( 'Cart-Hash', WC()->cart->get_cart_hash() );

	return $response;
}