Automattic\WooCommerce\Internal\Fulfillments\Providers
AustraliaPostShippingProvider::validate_country_pattern
Validate tracking number against country-specific patterns.
Method of the class: AustraliaPostShippingProvider{}
No Hooks.
Returns
true|false. True if valid, false otherwise.
Usage
// private - for code of main (parent) class only $result = $this->validate_country_pattern( $tracking_number, $country_code ): bool;
- $tracking_number(string) (required)
- The tracking number to validate.
- $country_code(string) (required)
- The country code for the shipment.
AustraliaPostShippingProvider::validate_country_pattern() AustraliaPostShippingProvider::validate country pattern code WC 10.3.3
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;
}