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

Automattic\WooCommerce\Blocks\StoreApi\Utilities

OrderController::validate_addresses() protected WC 1.0

Validates customer address data based on the locale to ensure required fields are set.

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

Хуков нет.

Возвращает

null. Ничего.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_addresses( \WC_Order $order );
\WC_Order $order (обязательный)
-

Код OrderController::validate_addresses() WC 5.2.2

<?php
protected function validate_addresses( \WC_Order $order ) {
	$errors           = new \WP_Error();
	$needs_shipping   = wc()->cart->needs_shipping();
	$billing_address  = $order->get_address( 'billing' );
	$shipping_address = $order->get_address( 'shipping' );

	if ( $needs_shipping && ! $this->validate_allowed_country( $shipping_address['country'], (array) wc()->countries->get_shipping_countries() ) ) {
		throw new RouteException(
			'woocommerce_rest_invalid_address_country',
			sprintf(
				/* translators: %s country code. */
				__( 'Sorry, we do not ship orders to the provided country (%s)', 'woocommerce' ),
				$shipping_address['country']
			),
			400,
			[
				'allowed_countries' => array_keys( wc()->countries->get_shipping_countries() ),
			]
		);
	}

	if ( ! $this->validate_allowed_country( $billing_address['country'], (array) wc()->countries->get_allowed_countries() ) ) {
		throw new RouteException(
			'woocommerce_rest_invalid_address_country',
			sprintf(
				/* translators: %s country code. */
				__( 'Sorry, we do not allow orders from the provided country (%s)', 'woocommerce' ),
				$billing_address['country']
			),
			400,
			[
				'allowed_countries' => array_keys( wc()->countries->get_allowed_countries() ),
			]
		);
	}

	if ( $needs_shipping ) {
		$this->validate_address_fields( $shipping_address, 'shipping', $errors );
	}
	$this->validate_address_fields( $billing_address, 'billing', $errors );

	if ( ! $errors->has_errors() ) {
		return;
	}

	$errors_by_code = [];
	$error_codes    = $errors->get_error_codes();
	foreach ( $error_codes as $code ) {
		$errors_by_code[ $code ] = $errors->get_error_messages( $code );
	}

	// Surface errors from first code.
	foreach ( $errors_by_code as $code => $error_messages ) {
		throw new RouteException(
			'woocommerce_rest_invalid_address',
			sprintf(
				/* translators: %s Address type. */
				__( 'There was a problem with the provided %s:', 'woocommerce' ) . ' ' . implode( ', ', $error_messages ),
				'shipping' === $code ? __( 'shipping address', 'woocommerce' ) : __( 'billing address', 'woocommerce' )
			),
			400,
			[
				'errors' => $errors_by_code,
			]
		);
	}
}