Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Created April 24, 2020 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/d27870899b1cd328ba609c9b087d26eb to your computer and use it in GitHub Desktop.
Save harishankerr/d27870899b1cd328ba609c9b087d26eb to your computer and use it in GitHub Desktop.
Belgium Zip code validation for WooCommerce
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