Magento 2 store owner requires customers’ address for shipping the ordered items.
Also, while creating a new customer account before ordering anything, it is good to get customers’ address data upfront so that they can quickly place the orders once the items are selected.
Moreover, it may happen that it is important to have the customers’ region data even for downloadable products in order to apply the tax according to region-specific rules.
For such address requirements, the default Magento 2 offers the database from which a customer can select their country, state, or city from the frontend.
However, a developer may require to add new region for specific country in Magento 2 database when a new region is created or it may be missing from the database for some reasons.
In this scenario, simply follow the below solution and let the customer select their region while creating a new account or placing an order in Magento 2 store:
Method to Add New Region for Specific Country in Magento 2:
Run the below SQL query:
default_name) VALUES ("country_code","region_code","region_name");
For example, I want to add a new region “Ladakh” for India as shown below:
The above example can be implemented with the below SQL query:
INSERT INTO directory_country_region(country_id, code, default_name) VALUES ("IN","Leh","ladakh");
Any doubts in the above solution can be mentioned in the Comments section below.
I’d be happy to help.
Also, do share the post with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.