Automattic\WooCommerce\StoreApi\Utilities

AgenticCheckoutUtils::add_protocol_headerspublic staticWC 1.0

Add Agentic Commerce Protocol headers to response.

Method of the class: AgenticCheckoutUtils{}

No Hooks.

Returns

\WP_REST_Response. Response with headers.

Usage

$result = AgenticCheckoutUtils::add_protocol_headers( $response, $request );
$response(WP_REST_Response) (required)
Response object.
$request(WP_REST_Request) (required)
Request object.

AgenticCheckoutUtils::add_protocol_headers() code WC 10.4.3

public static function add_protocol_headers( \WP_REST_Response $response, \WP_REST_Request $request ) {
	// Echo Idempotency-Key header if provided.
	$idempotency_key = $request->get_header( 'Idempotency-Key' );
	if ( $idempotency_key ) {
		$response->header( 'Idempotency-Key', $idempotency_key );
	}

	// Echo Request-Id header if provided.
	$request_id = $request->get_header( 'Request-Id' );
	if ( $request_id ) {
		$response->header( 'Request-Id', $request_id );
	}

	return $response;
}