Automattic\WooCommerce\Admin\Features\Fulfillments\Providers

AustraliaPostShippingProvider::validate_country_pattern │ private │ WC 1.0

Validate tracking number against country-specific patterns.

Метод класса: AustraliaPostShippingProvider{}

Хуков нет.

Возвращает

bool. True if valid, false otherwise.

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

// private - только в коде основоного (родительского) класса
$result = $this->validate_country_pattern( $tracking_number, $country_code ): bool;
$tracking_number(строка) (обязательный)
The tracking number to validate.
$country_code(строка) (обязательный)
The country code for the shipment.

Код AustraliaPostShippingProvider::validate_country_pattern() WC 11.2.2

private function validate_country_pattern( string $tracking_number, string $country_code ): bool {
	if ( ! isset( self::TRACKING_PATTERNS[ $country_code ] ) ) {
		return false;
	}

	foreach ( self::TRACKING_PATTERNS[ $country_code ]['patterns'] as $pattern ) {
		if ( preg_match( $pattern, $tracking_number ) ) {
			return true;
		}
	}
	return false;
}