Store
Community Documentation

v3 Knowledgebase

Countries and states/provinces

Depending of your needs, and the target audience, you could need to add more countries, remove countries or add states/provinces into a country.

Well, our AdminCP offers the tools to manage countries and states/provinces.

Let's start with the option to delete countries. To do so, log into your AdminCP and go to:
Tools >> Countries >> Country Manager

Once here, look for the country you want to delete, and click on the drop-down option next to the country. After that, just select "Delete".

If you want to delete a state/province in a country, click on the number next to the country, under the column "states/provinces". Once here, repeat the previous process: look for the state you want to delete, and click on the drop-down option next to the country. After that, just select "Delete".

To add one only country, log into your AdminCP and go to:
Tools >> Countries >> Add Country

You only need to enter two data here: The country iso (alpha-2) and the country name.

The process to add a state or province is very similar. Log into your AdminCP and go to:
Tools >> Countries >> Add State/Province

Once here, select the country where the state or province belongs, and enter the name of it.

This process could be very tedious if you want to massively add states or provinces into a country. Therefore, we have added an "import" tool to mass import a country with its states, or states to a country already added. Let's start with the mass import of a country with its states. I will call this country "Fakeland" and its states as "First fake", "Second fake", and so forth.

First, you need to get or create the country. It must be a .xml file with filename phpfox-country-fakeland.xml, where "fakeland" is the name of the country. The content of this file, must be similar to this:
HTML:
<country>
    <info>
        <iso>FL</iso>
        <name>Fakeland</name>
    </info>
    <children>
        <child>First state</child>
        <child>Second state</child>
        <child>Third state</child>
        <child>Fourth state</child>
        <child>Fifth state</child>
    </children>
</country>

Once you have the file, log into your AdminCP and go to:
Tools >> Countries >> Import

Here, use the "Import Country Package" to upload the .xml file. The option "overwrite" is meant to be used when the country exists, but you want to re-create it or add more states/provinces on it from the .xml file.

But what if the country already exists and I don't have a .xml file like the one above?
Well, as easy as create a .txt file with a list of states/provinces. Yes, just create a text file as follows:
HTML:
First state
Second state
Third state
Fourth state
Fifth state

Log into your AdminCP and go to:
Tools >> Countries >> Import

And use the "Import Text File" tool. Select the country where these states belong (in our case, let suppose we have already created the country "Fakeland"). The option "Enable UTF Encoding" is very useful if the list of states contains non-English characters. If the list uses only English characters, this option can remain as "No".