Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created July 16, 2012 17:22
Show Gist options
  • Save mikejolley/3123868 to your computer and use it in GitHub Desktop.
Save mikejolley/3123868 to your computer and use it in GitHub Desktop.
WooCommerce - India states
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter( 'woocommerce_states', 'indian_woocommerce_states' );
function indian_woocommerce_states( $states ) {
$states['IN'] = array(
'AP' => __('Andra Pradesh', 'woocommerce'),
'AR' => __('Arunachal Pradesh', 'woocommerce'),
'AS' => __('Assam', 'woocommerce'),
'BR' => __('Bihar', 'woocommerce'),
'CT' => __('Chhattisgarh', 'woocommerce'),
'GA' => __('Goa', 'woocommerce'),
'GJ' => __('Gujarat', 'woocommerce'),
'HR' => __('Haryana', 'woocommerce'),
'HP' => __('Himachal Pradesh', 'woocommerce'),
'JK' => __('Jammu and Kashmir', 'woocommerce'),
'JH' => __('Jharkhand', 'woocommerce'),
'KA' => __('Karnataka', 'woocommerce'),
'KL' => __('Kerala', 'woocommerce'),
'MP' => __('Madhya Pradesh', 'woocommerce'),
'MH' => __('Maharashtra', 'woocommerce'),
'MN' => __('Manipur', 'woocommerce'),
'ML' => __('Meghalaya', 'woocommerce'),
'MZ' => __('Mizoram', 'woocommerce'),
'NL' => __('Nagaland', 'woocommerce'),
'OR' => __('Orissa', 'woocommerce'),
'PB' => __('Punjab', 'woocommerce'),
'RJ' => __('Rajasthan', 'woocommerce'),
'SK' => __('Sikkim', 'woocommerce'),
'TN' => __('Tamil Nadu', 'woocommerce'),
'TR' => __('Tripura', 'woocommerce'),
'UT' => __('Uttaranchal', 'woocommerce'),
'UP' => __('Uttar Pradesh', 'woocommerce'),
'WB' => __('West Bengal', 'woocommerce'),
'AN' => __('Andaman and Nicobar Islands', 'woocommerce'),
'CH' => __('Chandigarh', 'woocommerce'),
'DN' => __('Dadar and Nagar Haveli', 'woocommerce'),
'DD' => __('Daman and Diu', 'woocommerce'),
'DL' => __('Delhi', 'woocommerce'),
'LD' => __('Lakshadeep', 'woocommerce'),
'PY' => __('Pondicherry (Puducherry)', 'woocommerce')
);
return $states;
}
@Neenad-Neo
Copy link

@mikejolley Is there a code to restrict the Pincodes and the Town City from the state ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment