Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::get_response
Get the route response based on the type of request.
Метод класса: Checkout{}
Хуков нет.
Возвращает
\WP_REST_Response.
Использование
$Checkout = new Checkout(); $Checkout->get_response( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Checkout::get_response() Checkout::get response WC 10.7.0
public function get_response( \WP_REST_Request $request ) {
$this->load_cart_session( $request );
$response = null;
$nonce_check = $this->requires_nonce( $request ) ? $this->check_nonce( $request ) : null;
if ( is_wp_error( $nonce_check ) ) {
$response = $nonce_check;
}
if ( ! $response ) {
try {
$response = $this->get_response_by_request_method( $request );
} catch ( InvalidCartException $error ) {
$response = $this->get_route_error_response_from_object( $error->getError(), $error->getCode(), $error->getAdditionalData() );
} catch ( RouteException $error ) {
$response = $this->get_route_error_response( $error->getErrorCode(), $error->getMessage(), $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 );
// If we encountered an exception, free up stock and release held coupons.
if ( $this->order ) {
wc_release_stock_for_order( $this->order );
wc_release_coupons_for_order( $this->order );
}
if ( $request->get_method() === \WP_REST_Server::CREATABLE ) {
// Step logs the exception. If nothing abnormal occurred during the place order POST request, flow the log is removed.
wc_log_order_step(
'[Store API #FAIL] Placing Order failed',
array(
'status' => $response->get_status(),
'data' => $response->get_data(),
),
true
);
}
}
return $this->add_response_headers( $response );
}