WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Routes

Checkout::prepare_item_for_response() public WC 1.0

Prepare a single item for response. Handles setting the status based on the payment result.

{} It's a method of the class: Checkout{}

No Hooks.

Return

WP_REST_Response. $response Response data.

Usage

$Checkout = new Checkout();
$Checkout->prepare_item_for_response( $item, $request );
$item(mixed) (required)
Item to format to schema.
$request(WP_REST_Request) (required)
Request object.

Code of Checkout::prepare_item_for_response() WC 5.7.1

public function prepare_item_for_response( $item, WP_REST_Request $request ) {
	$response = parent::prepare_item_for_response( $item, $request );

	if ( isset( $item->payment_result ) && $item->payment_result instanceof PaymentResult ) {
		switch ( $item->payment_result->status ) {
			case 'success':
				$response->set_status( 200 );
				break;
			case 'pending':
				$response->set_status( 202 );
				break;
			case 'failure':
				$response->set_status( 400 );
				break;
			case 'error':
				$response->set_status( 500 );
				break;
		}
	}

	return $response;
}