WooCommerce - disable postcode validation
Adding this code to the functions.php file should work:
function custom_override_default_address_fields( $address_fields ) { unset( $address_fields['postcode'] ); return $address_fields;}
EDIT:
// Hook into the checkout fields (shipping & billing)add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );// Hook into the default fieldsadd_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );function custom_override_checkout_fields( $fields ) { unset( $fields['billing']['billing_postcode'] ); unset( $fields['shipping']['shipping_postcode'] ); return $fields;}function custom_override_default_address_fields( $address_fields ) { unset( $address_fields['postcode'] ); return $address_fields;}
ANOTHER EDIT:
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );function custom_override_default_address_fields( $address_fields ) { $address_fields['postcode']['required'] = false; return $address_fields;}
So I didn't actually find a simple code solution for this one but I noticed that if I set
WooCommerce > Preferences > General > Geolocate address
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:
add_filter( 'woocommerce_default_address_fields', 'custom_override_default_address_fields' );function custom_override_default_address_fields($address_fields){ $address_fields['postcode']['validate'] = false; return $address_fields;}
for billing and shipping:
add_filter( 'woocommerce_checkout_fields' , 'remove_postcode_validation', 99 );function remove_postcode_validation( $fields ) {unset($fields['billing']['billing_postcode']['validate']);unset($fields['shipping']['shipping_postcode']['validate']);return $fields;}
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.