List of countries and their states in wordpress

Where is the list of countries and states located in Wordpress? When you select the USA on the statement form, the “state” field changes immediately to contain a list of states. I would like to imitate this behavior for other countries. For example, when you select Honduras, you will get a list of states of this country.

Is there an XML file, php file, or database table in which Wordpress accesses this information? so that it can be edited to add states without adding a plugin or adding additional code.

I know that you can access the list from code using WC()->countries->get_stateshow does it ever get it?

+4
source share
1 answer

There is a folder with a name i18n, and in this folder there is another folder with a name statesthat contains a list of files. Add your file HN.phpwith a list of states that you want to show there, for example:

<?php
/**
 * Honduras
 *
 * @author      WooThemes
 * @category    i18n
 * @package     WooCommerce/i18n
 * @version     2.0.0
 */
global $states;

$states['HN'] = array(
'AA' => __( 'Some state', 'woocommerce' ),
);
+3
source

Source: https://habr.com/ru/post/1538306/


All Articles