Automattic\WooCommerce\StoreApi\Routes\V1

Checkout::get_route_post_responseprotectedWC 1.0

Process an order.

Method of the class: Checkout{}

No Hooks.

Returns

\WP_REST_Response|\WP_Error.

Usage

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

Checkout::get_route_post_response() code WC 10.9.1

protected function get_route_post_response( \WP_REST_Request $request ) { // phpcs:ignore Squiz.Commenting.FunctionComment.IncorrectTypeHint
	try {
		return $this->process_order( $request );
	} catch ( \Throwable $exception ) {
		if ( $this->order ) {
			// The optimistic order save bounced back, persist the order as it is to preserve the intermediate state.
			try {
				$this->order->save();
			} catch ( \Throwable $save_exception ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
				// Ignore the save exception, the root cause will be bubbled up via re-throwing $exception.
			}
		}
		throw $exception;
	}
}