This is a simple guide about how to add States, Cities, and Postcodes relationship to WooCommerce by Country, using the plugin WC Provincia Canton Distrito. This requires access to the source code of your site and minimal knowledge of coding.
Step #1
Copy the main json file from /assets/js/prov-cant-dist.json to /your-theme/assets/js/prov-cant-dist.json. If you don’t need it on this location, you can use the filter wcpcd_prov_cant_dist_json to move it to your custom location.
Step #2
Map your current country, state, city, and postcode information to the json file located in your plugin. As an example, this is part of the mapping information for Ecuador Thanks to José Leones.

Step #3
Map your states to WooCommerce in relation to your country. This is required to become the state field on the Checkout as a dropdown. Based on the same example of Ecuador, you need to use the filter woocommerce_states.
function kmchild_wc_states($states) {
$states['EC'] = array(
'A' => 'Azuay',
'B' => 'Bolívar',
'P' => 'Pichincha'
);
return $states;
}
add_filter('woocommerce_states', 'kmchild_wc_states');
Result
Now, you’ll be able to choose Country (optional), State, State-District and it places the postcode related to the postcode field.


I hope that these instructions help you to use this plugin with your country information. Don’t hesitate to contact me in case you need anything else.
Update 01-2021: Now you can get or share your country’s State and cities locations. Please, visit State and cities locations to get more information about it.
Any doubts or suggestions?
2 replies on “Add States and Cities to WooCommerce (Provincia, Cantones)”
Felicitaciones Keylor, que buen plugin, donde puedo descargar el archivo para el mapeo de las provincias y cantones de ecuador
Hola Pablo, muchas gracias y espero que le sea de mucha utilidad el plugin. Disculpe la tardanza en responder.
Este archivo no es de mi autoría, sin embargo la persona que lo hizo accedió a compartirlo, de ahí la idea de centralizarlos en este enlace para que puedan ser descargados: https://keylormendoza.com/how-to/state-and-cities-locations/
Saludos