Today we are going to talk about adding state(s) to countries in WooCommerce. You have to paste the following function in your active/child theme’s function.php file.
add_filter('woocommerce_states', 'qaisarsatti_country_states');
function qaisarsatti_country_states( $states ) {
// If states already exist
if( isset($states['US'] ) ) {
$states['AE']['LA'] = __('Los Angeles', 'woocommerce');
}
// IF states don't exist for
else {
$states['US'] = array(
'LA' => __('Los Angeles', 'woocommerce'),
);
}
return $states;
}
function qaisarsatti_country_states( $states ) {
// If states already exist
if( isset($states['US'] ) ) {
$states['AE']['LA'] = __('Los Angeles', 'woocommerce');
}
// IF states don't exist for
else {
$states['US'] = array(
'LA' => __('Los Angeles', 'woocommerce'),
);
}
return $states;
}