By default, Woocommerce only validates ZIP code of few countries only. Woocommerce stores in India, are thus invalidated in case of PINCODE inputs from customers. Here is how you can enable checking of pincode for India woocommerce:
Put the following code in your custom function file or child theme functions.php
add_filter('woocommerce_validate_postcode','validate_indian_postcode',10,3);
function validate_indian_postcode($valid, $postcode, $country){
if($country=="IN")
$valid = (bool) preg_match( '/^([0-9]{6})$/', $postcode );
// checks your $postcode, if valid $valid will be true because of preg_match else false
return $valid;
}
Leave a Reply