magento custom states for country

magento custom states for country

September 1, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento custom states for country

Customizing Magento: Adding Local States for the UK

As a Magento developer working on the latest version of this powerful e-commerce platform, you might find yourself needing to add custom states or regions for countries like the United Kingdom. In this guide, I’ll walk you through the process of adding local states such as Manchester, London, and Yorkshire to your UK store.

Understanding Magento’s Default Country/Region Configuration

By default, Magento uses a combination of the core_country and directory_country_region tables in your database to manage countries and their respective regions or states. When you install Magento with sample data, it populates these tables with pre-defined values for various countries around the world.

However, if you want to add custom states specific to the UK (or any other country), you’ll need to modify this default setup.

Adding a Custom State: The Database Approach

To add a new state or region for your UK store, you can directly insert data into the directory_country_region table. Here’s an example SQL query that adds Manchester as a custom state:

INSERT INTO directory_country_region
SET
country_id = 'GB',  -- ISO code for the United Kingdom
code = 'MAN',
name = 'Manchester';

Replace 'GB' with the appropriate ISO country code if needed. You can find a list of ISO country codes on Laravel Company’s website.

Similarly, you can add other custom states like London and Yorkshire by running similar INSERT queries with their respective names.

Updating the Admin Interface

After adding your custom states to the database, you’ll need to update the admin interface so that these options appear in the shipping settings. To do this, navigate to Admin -> Stores -> Settings -> Configuration -> General -> General.

In the “Country Options” section, you should see a dropdown list for “Allow Countries”. Make sure “GB - United Kingdom” is selected.

Updating Shipping and Billing Addresses

To ensure that your custom UK states appear in the shipping and billing address fields on the frontend, Magento uses the directory_country_region table during form rendering. This means you don’t need to modify any core files; the changes you made to the database will automatically reflect on the frontend.

However, if you want to set Manchester (or another custom state) as the default shipping destination for your UK store, you can do so in the admin interface under Admin -> Stores -> Configuration -> General -> General.

Making the UK the Default Country

To ensure that the United Kingdom is always selected by default when a customer starts the checkout process or updates their address book, update the core_config_data table:

UPDATE core_config_data
SET value = 'GB'
WHERE path = 'general/country/default';

This query sets the default country to the UK.

A Final Note on Testing

Remember to clear your Magento cache and reindex after making these changes. You can do this in the admin interface under System -> Cache Management and System -> Index Management.

Testing is crucial, so always verify that your custom states appear as expected during the checkout process and address book management.

Conclusion: Customizing Magento for Local Needs

Adding custom states to Magento requires a combination of database modifications and administrative configuration changes. By directly updating the directory_country_region table and configuring your admin settings accordingly, you can create a tailored shopping experience for customers in countries like the UK.

If you find yourself needing further guidance on Magento customizations or other e-commerce development tasks, feel free to explore Laravel Company’s resources on Magento development. Our team of experienced developers is always ready to help you tackle even the most complex projects.

Database Configuration

Our network