How to Add Indian States Dropdown in Magento 1 or Magento 2
Default Magento 1 and Magento 2 (Until Magento 2.2.4) don’t provide the states dropdown for many countries like Nepal, India, Bangladesh etc. The state list is badly required when you are creating shipping rules, setting a default state for a country, allowing customers to select shipping state in India while placing orders and many other reasons. Also you can add Magento 2 week days list to choose days of the week to exclude or include in the module’s functionalities.
While working with Indian clients and projects, developing extensions such as Magento GST and Magento 2 GST, we often require to add Indian states drop-down in Magento 1 and Magento 2 backend and frontend. If you are also working with something related to Indian states, you may also require a drop-down list for Indian states. Today, I’m sharing an SQL script for you to run to add Indian states Dropdown in Magento.
The script works with adding Indian states in Magento 1 & 2 backend and frontend both.
Run Below SQL Query to Add Indian States Dropdown in Magento 1 or Magento 2:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
INSERT INTO `directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES (NULL , 'IN', 'AN','Andaman Nicobar'), (NULL , 'IN', 'AP','Andhra Pradesh'), (NULL , 'IN', 'AR','Arunachal Pradesh'), (NULL , 'IN', 'AS','Assam'), (NULL , 'IN', 'BH','Bihar'), (NULL , 'IN', 'CH','Chandigarh'), (NULL , 'IN', 'CG','Chhattisgarh'), (NULL , 'IN', 'DN','Dadra Nagar Haveli'), (NULL , 'IN', 'DD','Daman Diu'), (NULL , 'IN', 'DL','Delhi'), (NULL , 'IN', 'GA','Goa'), (NULL , 'IN', 'GJ','Gujarat'), (NULL , 'IN', 'HR','Haryana'), (NULL , 'IN', 'HP','Himachal Pradesh'), (NULL , 'IN', 'JK','Jammu Kashmir'), (NULL , 'IN', 'JH','Jharkhand'), (NULL , 'IN', 'KA','Karnataka'), (NULL , 'IN', 'KL','Kerala'), (NULL , 'IN', 'LD','Lakshadweep'), (NULL , 'IN', 'MP','Madhya Pradesh'), (NULL , 'IN', 'MH','Maharashtra'), (NULL , 'IN', 'MN','Manipur'), (NULL , 'IN', 'ML','Meghalaya'), (NULL , 'IN', 'MZ','Mizoram'), (NULL , 'IN', 'NL','Nagaland'), (NULL , 'IN', 'OR','Odisha'), (NULL , 'IN', 'PY','Pondicherry'), (NULL , 'IN', 'PB','Punjab'), (NULL , 'IN', 'RJ','Rajasthan'), (NULL , 'IN', 'SK','Sikkim'), (NULL , 'IN', 'TN','Tamil Nadu'), (NULL , 'IN', 'TG','Telangana'), (NULL , 'IN', 'TR','Tripura'), (NULL , 'IN', 'UP','Uttar Pradesh'), (NULL , 'IN', 'UT','Uttaranchal'), (NULL , 'IN', 'WB','West Bengal'); INSERT INTO directory_country_region_name( locale, region_id, name ) SELECT 'en_US' AS "language", region_id, default_name FROM `directory_country_region` WHERE country_id = 'IN'; |
Let me know where and for which extension you used this SQL query? Suggestions & further doubts are always welcomed in the comments section below. Rate the post with 5 stars to appreciate the blog 🙂
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
2 Comments
Hi i have used your query for displaying indian states in checkout and comes fine. But in My Account->Address book while adding new address the state/ Province is displayed as textbox rather than dropdown. How can i overcome this. Any suggesstions
Hello Muthu Kumar,
I’ve check in Magento 2.2.1 and it works fine – https://drops.meetanshi.com/z0Y71V
Thank you.