Created
April 24, 2020 19:43
-
-
Save harishankerr/d27870899b1cd328ba609c9b087d26eb to your computer and use it in GitHub Desktop.
Belgium Zip code validation for WooCommerce
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
add_filter('woocommerce_validate_postcode','woo_validate_belgium_postcode',10,3); | |
function woo_validate_belgium_postcode($valid, $postcode, $country){ | |
if($country=="BE") | |
$valid = (bool) preg_match( '/^([0-9]{4})$/', $postcode ); | |
// Checks your postcode to seee if it matches belgium (4 digits). If not, it will reject validation. | |
return $valid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment