Does anybody know how to disable the Postcode validation on the checkout page in WooCommerce?
My country is set up as Switzerland, but I want also people from Austria and Germany allow to order.
So when I enter a German Postcode with 5 digits (in Switzerland there are only 4), the shop says it’s an invalid postcode. (but in the settings I allowed every country).
Any idea how to fix that?
Adding this code to the functions.php file should work:
EDIT:
ANOTHER EDIT:
So I didn’t actually find a simple code solution for this one but I noticed that if I set
it will work (if settings are set to “Sell to all countries”, in my case)
This code only removes validation of address fields in my-account page, what you need:
for billing and shipping:
Also i think with removing “validate-required” class in wc-template-function.php, this feature will be deactivated (no test).
Sorry for bad English and hope this solutions solve your problem.
The previous answers don’t seem to address the question! The postcode is still a required field, it’s matter of whether other postcodes can be allowed that WooCommerce is saying is wrong.
For a checkout I’m building I’ve used this filter to allow any postcode to be considered valid regardless of country/postcode given.
You can change that
return true;
for more complex code logic that reviews the postcode and country, this can help if your version of WooCommerce doesn’t cover new postcode/zip code rules and you need them to be accepted.Source: https://github.com/EloxZ/wordpresscrm/blob/main/wp-content/plugins/woocommerce/includes/class-wc-validation.php#L123