Today I'm discussing how to add states for indian country in magento checkout page.
By default Magento stores the region/state information only for some countries – Austria, United States, Canada, France, Germany etc. So on the checkout and registration pages Magento will display the state/region dropdown for only these countries and for other counties region/state will be shown as a textbox.
If region/state data is not available for your country in Magento then the solution is to add this information to the tables in your database. State/region tables in magento are `directory_country_region` and `directory_country_region_name`. The table `directory_country_region` holds the region – country mapping and `directory_country_region_name` holds the translation for region name based on your locale.
[php]
INSERT INTO `directory_country_region` (`country_id`, `code`, `default_name`) VALUES
('IN', 'IN-AN', 'Andaman & Nicobar Islands'),
('IN', 'IN-AP', 'Andhra Pradesh'),
('IN', 'IN-AR', 'Arunachal Pradesh'),
('IN', 'IN-AS', 'Assam'),
('IN', 'IN-BR', 'Bihar'),
('IN', 'IN-CH', 'Chandigarh'),
('IN', 'IN-CT', 'Chattisgarh'),
('IN', 'IN-DN', 'Dadra & Nagar Haveli'),
('IN', 'IN-DD', 'Daman & Diu'),
('IN', 'IN-DL', 'Delhi'),
('IN', 'IN-GA', 'Goa'),
('IN', 'IN-GJ', 'Gujrat'),
('IN', 'IN-HR', 'Haryana'),
('IN', 'IN-HP', 'Himachal Pradesh'),
('IN', 'IN-JK', 'Jammu & Kashmir'),
('IN', 'IN-JH', 'Jharkhand'),
('IN', 'IN-KA', 'Karnataka'),
('IN', 'IN-KL', 'Kerala'),
('IN', 'IN-LD', 'Lakshwdeep'),
('IN', 'IN-MP', 'Madhya Pradesh'),
('IN', 'IN-MH', 'Maharashtra'),
('IN', 'IN-MN', 'Manipur'),
('IN', 'IN-ML', 'Meghalaya'),
('IN', 'IN-MZ', 'Mizoram'),
('IN', 'IN-NL', 'Nagaland'),
('IN', 'IN-OR', 'Orissa'),
('IN', 'IN-PY', 'Pondicherry'),
('IN', 'IN-PB', 'Punjab'),
('IN', 'IN-RJ', 'Rajasthan'),
('IN', 'IN-SK', 'Sikkim'),
('IN', 'IN-TN', 'Tamilnadu'),
('IN', 'IN-TR', 'Tripura'),
('IN', 'IN-UP', 'Uttar Pradesh'),
('IN', 'IN-UT', 'Uttarakhand'),
('IN', 'IN-WB', 'West Bengal');
INSERT INTO `directory_country_region_name` (`locale` ,`region_id` ,`name` )
SELECT 'en_US', tmp.region_id, tmp.default_name FROM `directory_country_region`
AS tmp WHERE tmp.country_id='IN';
[/php]
After running these queries in database, Magento will automatically displayed the states/region option as a dropdown on the checkout pages in address block when the country was selected as “India”.
while I was searching on Bing for something else, Anyhow I am here now and would
just like to say thanks a lot for a incredible post and a all round interesting blog (I also love the theme/design), I don't have time
to read it all at the minute but I have bookmarked it and also added
in your RSS feeds, so when I have time I will be back to read more,
Please do keep up the great job.