Skip to content

Latest commit

 

History

History
 
 

templates

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Adding a new country

If you want to add a new country that is not yet in the list of Supported Countries, please follow this guide to send a pull request.

Getting started

  1. Fork the plugin repository on your GitHub account.
  2. Refer to WooCommerce country codes to find the code related to your country. E.g. 'NG' for Nigeria, 'ES' for Spain, 'VE' for Venezuela.
  3. Duplicate (DO NOT EDIT DIRECTLY!) the XX.php file you'll find inside template/states/ and template/places/, rename them with the code of your country you found in the previous step (E.g. NG.php, ES.php, VE.php) and move them to trunk/states and trunk/places/ respectively.
# Please remember:
- Do not edit the templates files directly: 
+ Duplicate them in their respective folder (trunk/states/ & trunk/places/) and then update the country code.

Setting up the States

  1. Go to the states/ directory and open the file you just move from template/states/ with your favourite code editor.
  2. Find the $states['XX'] (line 19) and replace 'XX' with your country code.
  3. Some countries like Denmark or Belgium do not use the state field. If your country doesn't use it either, leave the array empty to disable the State field:
// Disable the State field
$states['DK'] = array();

Otherwise, if the state field is used in your country, start adding your Country States: Add a Code to each State using a logic sense (E.g. 'FA' => 'Florida'). This code will be used to map the Places beloging this State. You can use any standar like ISO, ANSI, etc. There is no an mandatory standar or system and you can use your own. Please see the U.S. state abbreviations to see an example.

  1. Edit the header comment with your credits and the source(s) link(s) where you got the info of Places. We'll check the list before accept your pull request. You should also remove all the comments after line 17 (that is a resume of this guide to ease the job).

Your code should look like this:

$states['VE'] = array(
  'AM' => 'Amazonas',
  'AN' => 'Anzoátegui',
  'AP' => 'Apure',
  'AR' => 'Aragua',
  [...]
);

Note: "States" is the generic name equivalent to first-level administrative divisions likes States, Provinces, Regions, Departments or whatever this subdivision is called in your country.

Setting up the Places

  1. Go to the places/ directory and open the file you just move from template/places/ with your favourite code editor.
  2. Find $places['XX'] (line 19) and replace 'XX' with your country code.
  3. Find 'AA' => array( (line 19) and replace 'AA' with the first State Code you entered in the states file in the previous section.
  4. Begin adding the State places: Add a place per line as follows:
    'Location 1',
    'Location 2',
    'Location 3',
    [...]
    
  5. Repeat steps 3 and 4 as many times as States you entered in the states file in the previous section.
  6. Edit the header comment with your credits and the source(s) link(s) where you got the info of Places. We'll check the list before accept your pull request. You should also remove all the comments after line 17 (that is a resume of this guide to ease the job).

Your code should look like this:

$places['VE'] = array(
  'AM' => array(
    'Alto Orinoco (La Esmeralda)',
    'Atabapo (San Fernando de Atabapo)',
    [...]
  ),
  'AN' => array(
    'Anaco (Anaco)',
    'Aragua (Aragua de Barcelona)',
    [...]
  ),
  'AP' => array(
    'Achaguas (Achaguas)',
    'Biruaca (Biruaca)',
    [...]
  ),
  'AR' => array(
    'Bolívar (San Mateo)',
    'Camatagua (Camatagua)',
    [...]
  ),
  [...]
);

Note: "Places" is the generic name equivalent to second-level administrative divisions likes Cities, Municipalities, Districts, Communes or whatever this subdivision is called in your country.

Send a pull request

If you completed the steps above, you're ready to send a pull request. Thanks in advance for your contribution to improve this plugin.

...if you are not familiar with GitHub workflow

If your don't know or don't want to use GitHub workflow, please follow the following steps to add your country to the plugin:

  1. Click here to download the wc-states-places-country-templates.zip file.
  2. Uncompress and edit both template/states/XX.po and template/places/XX.po, adding the location data for your country.
  3. Send the files to this email: [email protected].
  4. Thanks in advance for your contribution to improve this plugin.