Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::get_route_update_response
Get route response for PUT requests.
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_update_response( $request );
- $request(WP_REST_Request) (required)
- Request object.
Checkout::get_route_update_response() Checkout::get route update response code WC 10.8.1
protected function get_route_update_response( \WP_REST_Request $request ) {
$validation_callback = $this->validate_callback( $request );
if ( is_wp_error( $validation_callback ) ) {
return $validation_callback;
}
/**
* Create (or update) Draft Order and process request data.
*/
$this->create_or_update_draft_order( $request );
/**
* Persist additional fields, order notes and payment method for order.
*/
$this->update_order_from_request( $request );
if ( $request->get_param( '__experimental_calc_totals' ) ) {
/**
* Before triggering validation, ensure totals are current and in turn, things such as shipping costs are present.
* This is so plugins that validate other cart data (e.g. conditional shipping and payments) can access this data.
*/
$this->cart_controller->calculate_totals();
/**
* Validate that the cart is not empty.
*/
$this->cart_controller->validate_cart_not_empty();
/**
* Validate items and fix violations before the order is processed.
*/
$this->cart_controller->validate_cart();
}
$this->order->save();
return $this->prepare_item_for_response(
(object) [
'order' => wc_get_order( $this->order ),
'cart' => $this->cart_controller->get_cart_instance(),
],
$request
);
}