How To Add States do the WooCommerce plugin?
I started creating a very small and fast eCommerce on WordPress, so i decided to give the WooCommerce Plugin a go.
Must say, the interface is pretty neat but lacks some extra support, like adding new states that I’m about to show you how to do. Btw, this is something really easy to acomplish, all you need is follow the bellow steps and everything should work just fine
1. Open the file countries.class.php in the classes folder inside woocommerce plugin folder.
2. Look for the code of your country, you can find that in the var $countries = array, for instance, the code for Brazil is BR
3. Look for the Line var $states = array(… (this will be right bellow the var $countries array)
4. Inside the above array, go to the last line of that array (will probabiliy be the USAF array), and now all you have to do is create a new one right bellow that, if I were to add the brazilian states I would do the following:
[crayon attributes lang="php"]
‘USAF’ => array(
‘AA’ => ‘Americas’ ,
‘AE’ => ‘Europe’ ,
‘AP’ => ‘Pacific’
), // NEVER FORGET THE COMMA
‘BR’ => array(
‘AM’ => ‘Amazonas’,
‘SP’ => ‘Sao Paulo’,
…
)
[/crayon]
Just a heads up, the plugin is bugging for states with UTF-8 caracters, so you have to add Sao Paulo instead of São Paulo or any other state name with é, è, â… you got the idea.
Save the file, upload and profit
Any doubts, leave a comment bellow.