WC_Validation::is_postcode
Checks for a valid postcode.
Method of the class: WC_Validation{}
Hooks from the method
Returns
bool.
Usage
$result = WC_Validation::is_postcode( $postcode, $country );
- $postcode(string) (required)
- Postcode to validate.
- $country(string) (required)
- Country to validate the postcode for.
WC_Validation::is_postcode() WC Validation::is postcode code WC 11.2.2
public static function is_postcode( $postcode, $country ) {
if ( strlen( trim( preg_replace( '/[\s\-A-Za-z0-9]/', '', $postcode ) ) ) > 0 ) {
return false;
}
$valid = Automattic\WooCommerce\Internal\Utilities\PostcodeValidation::validate( (string) $postcode, (string) $country );
$valid = null === $valid ? true : $valid;
return apply_filters( 'woocommerce_validate_postcode', $valid, $postcode, $country );
}