Automattic\WooCommerce\StoreApi\Routes\V1

AbstractRoute::get_response()publicWC 1.0

Get the route response based on the type of request.

{} Это метод класса: AbstractRoute{}

Хуков нет.

Возвращает

\WP_REST_Response.

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

$AbstractRoute = new AbstractRoute();
$AbstractRoute->get_response( $request );
$request(\WP_REST_Request) (обязательный)
Request object.

Код AbstractRoute::get_response() WC 6.7.0

public function get_response( \WP_REST_Request $request ) {
	$response = null;
	try {
		switch ( $request->get_method() ) {
			case 'POST':
				$response = $this->get_route_post_response( $request );
				break;
			case 'PUT':
			case 'PATCH':
				$response = $this->get_route_update_response( $request );
				break;
			case 'DELETE':
				$response = $this->get_route_delete_response( $request );
				break;
			default:
				$response = $this->get_route_response( $request );
				break;
		}
	} catch ( RouteException $error ) {
		$response = $this->get_route_error_response( $error->getErrorCode(), $error->getMessage(), $error->getCode(), $error->getAdditionalData() );
	} catch ( InvalidCartException $error ) {
		$response = $this->get_route_error_response_from_object( $error->getError(), $error->getCode(), $error->getAdditionalData() );
	} catch ( \Exception $error ) {
		$response = $this->get_route_error_response( 'woocommerce_rest_unknown_server_error', $error->getMessage(), 500 );
	}

	if ( is_wp_error( $response ) ) {
		$response = $this->error_to_response( $response );
	}

	return $response;
}