Automattic\WooCommerce\Blocks\StoreApi\Routes
Checkout::get_route_post_response() protected WC 1.0
Update and process an order.
- Obtain Draft Order
- Process Request
- Process Customer
- Validate Order
- Process Payment
{} Это метод класса: Checkout{}
Хуки из метода
Возвращает
WP_REST_Response
. Ничего.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_route_post_response( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Checkout::get_route_post_response() Checkout::get route post response WC 5.2.2
protected function get_route_post_response( WP_REST_Request $request ) {
/**
* Validate items etc are allowed in the order before the order is processed. This will fix violations and tell
* the customer.
*/
$this->cart_controller->validate_cart_items();
$this->cart_controller->validate_cart_coupons();
/**
* Obtain Draft Order and process request data.
*
* Note: Customer data is persisted from the request first so that OrderController::update_addresses_from_cart
* uses the up to date customer address.
*/
$this->update_customer_from_request( $request );
$this->create_or_update_draft_order();
$this->update_order_from_request( $request );
/**
* Process customer data.
*
* Update order with customer details, and sign up a user account as necessary.
*/
$this->process_customer( $request );
/**
* Validate order.
*
* This logic ensures the order is valid before payment is attempted.
*/
$this->order_controller->validate_order_before_payment( $this->order );
/**
* WooCommerce Blocks Checkout Order Processed (experimental).
*
* This hook informs extensions that $order has completed processing and is ready for payment.
*
* This is similar to existing core hook woocommerce_checkout_order_processed. We're using a new action:
* - To keep the interface focused (only pass $order, not passing request data).
* - This also explicitly indicates these orders are from checkout block/StoreAPI.
*
* @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3238
* @internal This Hook is experimental and may change or be removed.
*
* @param WC_Order $order Order object.
*/
do_action( '__experimental_woocommerce_blocks_checkout_order_processed', $this->order );
/**
* Process the payment and return the results.
*/
$payment_result = $this->order->needs_payment() ? $this->process_payment( $request ) : $this->process_without_payment( $request );
return $this->prepare_item_for_response(
(object) [
'order' => wc_get_order( $this->order ),
'payment_result' => $payment_result,
],
$request
);
}