WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Automattic\WooCommerce\Blocks\StoreApi\Routes

Checkout::get_route_post_response() protected WC 1.0

Update and process payment for the order.

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

Хуков нет.

Возвращает

\WP_REST_Response.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_route_post_response( \WP_REST_Request $request );
$request(\WP_REST_Request) (обязательный)
Request object.

Код Checkout::get_route_post_response() WC 4.7.1

<?php
protected function get_route_post_response( \WP_REST_Request $request ) {
	$order_controller = new OrderController();
	$order_object     = $this->get_draft_order_object( $this->get_draft_order_id() );

	if ( ! $order_object ) {
		throw new RouteException(
			'woocommerce_rest_checkout_invalid_order',
			__( 'This session has no orders pending payment.', 'woocommerce' ),
			500
		);
	}

	// Ensure order still matches cart.
	$order_controller->update_order_from_cart( $order_object );

	// If any form fields were posted, update the order.
	$this->update_order_from_request( $order_object, $request );

	// Check order is still valid.
	$order_controller->validate_order_before_payment( $order_object );

	// Create a new user account as necessary.
	// Note - CreateAccount class includes feature gating logic (i.e. this
	// may not create an account depending on build).
	try {
		$create_account = Package::container()->get( CreateAccount::class );
		$create_account->from_order_request( $order_object, $request );
	} catch ( Exception $error ) {
		$this->handle_error( $error );
	}

	// Persist customer address data to account.
	$order_controller->sync_customer_data_with_order( $order_object );

	if ( ! $order_object->needs_payment() ) {
		$payment_result = $this->process_without_payment( $order_object, $request );
	} else {
		$payment_result = $this->process_payment( $order_object, $request );
	}

	$response = $this->prepare_item_for_response(
		(object) [
			'order'          => wc_get_order( $order_object ),
			'payment_result' => $payment_result,
		],
		$request
	);

	switch ( $payment_result->status ) {
		case 'success':
			$response->set_status( 200 );
			break;
		case 'pending':
			$response->set_status( 202 );
			break;
		case 'failure':
			$response->set_status( 400 );
			break;
		case 'error':
			$response->set_status( 500 );
			break;
	}

	return $response;
}