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:
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';
Once the above SQL script is run correctly, Indian states dropdown is shown while the selection of India as the country. You can make use of this SQL script anywhere to add Indian states dropdown in Magento 1 or Magento 2.