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

Automattic\WooCommerce\Blocks\StoreApi\Routes

CartUpdateShipping::get_route_post_response() protected WC 1.0

Handle the request and return a valid response for this endpoint.

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

Хуков нет.

Возвращает

\WP_REST_Response.

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

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

Код CartUpdateShipping::get_route_post_response() WC 4.7.1

<?php
protected function get_route_post_response( \WP_REST_Request $request ) {
	if ( ! wc_shipping_enabled() ) {
		throw new RouteException( 'woocommerce_rest_shipping_disabled', __( 'Shipping is disabled.', 'woocommerce' ), 404 );
	}

	$controller = new CartController();
	$cart       = $controller->get_cart_instance();
	$request    = $this->validate_shipping_address( $request );

	// Update customer session.
	wc()->customer->set_props(
		array(
			'shipping_first_name' => isset( $request['first_name'] ) ? $request['first_name'] : null,
			'shipping_last_name'  => isset( $request['last_name'] ) ? $request['last_name'] : null,
			'shipping_country'    => isset( $request['country'] ) ? $request['country'] : null,
			'shipping_state'      => isset( $request['state'] ) ? $request['state'] : null,
			'shipping_postcode'   => isset( $request['postcode'] ) ? $request['postcode'] : null,
			'shipping_city'       => isset( $request['city'] ) ? $request['city'] : null,
			'shipping_address_1'  => isset( $request['address_1'] ) ? $request['address_1'] : null,
			'shipping_address_2'  => isset( $request['address_2'] ) ? $request['address_2'] : null,
		)
	);
	wc()->customer->save();

	$cart->calculate_shipping();
	$cart->calculate_totals();

	return rest_ensure_response( $this->schema->get_item_response( $cart ) );
}