Created
August 1, 2019 10:15
-
-
Save grola/b07c66eebdba3a5fc73f8f34f3ecac89 to your computer and use it in GitHub Desktop.
Validate polish postcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Validate polish postcode. "-" is required. | |
* | |
* @param bool $valid . | |
* @param string $postcode . | |
* @param string $country . | |
* | |
* @return bool | |
*/ | |
function wpdesk_validate_polish_postcode( $valid, $postcode, $country ) { | |
if ( 'PL' === $country ) { | |
$valid = (bool) preg_match( '/^([0-9]{2})-([0-9]{3})$/', $postcode ); | |
} | |
return $valid; | |
} | |
add_filter( 'woocommerce_validate_postcode', 'wpdesk_validate_polish_postcode', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment