How to filter and validate pincode in Indian woocommerce?

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


function validate_indian_postcode($valid, $postcode, $country){
			$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;