Same problem here but for WC sites in Chile.
Tested for WC sites in Argentina and No problem.
Another user has reported the same problem for WC sites in Brazil. https://goo.gl/8EpQQB
Thanks!
Plugin Support
Hannah S.L.
(@fernashes)
Automattic Happiness Engineer
WooCommerce shows shipping and billing address fields that are relevant for that country. Sweden (as an example) doesn’t usually use the state in addresses, which is why it’s not included.
If you’d like to modify the behavior for your specific site, then here’s a good place to get started:
https://www.xadapter.com/enable-shipping-state-field-for-specific-countries-during-woocommerce-checkout/
If you feel this is a bug, please do report it on the WooCommerce Github repo:
https://github.com/woocommerce/woocommerce/issues/new/choose
@sebaros – can you please start your own topic? While it sounds like it may be related, it’s far easier to troubleshoot one issue per thread.
Thread Starter
owyvan
(@owyvan)
@fernashes
@sebaros
I Did try the code,
function xa_filter_woocommerce_states( $states ) {
unset( $states['AF'] );
var_dump( $states ) ;
return $states;
};
add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );
function xa_filter_woocommerce_get_country_locale( $locale ) {
$locale['AF']['state']['required'] = true;
return $locale;
};
add_filter( 'woocommerce_get_country_locale', 'xa_filter_woocommerce_get_country_locale', 10, 1 );
But it was messy. I got a lot of random text on my checkout page. Instead I used,
add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );
which made it possible to show State Field on all countries. Hope this helps anyone else having the same issue.
-
This reply was modified 7 years, 9 months ago by
owyvan.
-
This reply was modified 7 years, 9 months ago by
owyvan.
@owyvan
The functions.php code below does work, but it causes two issues:
1. The dropdown list for countries with states, such as the United States, are overridden and do not appear as they did before this code was added. This forces the customer to manually enter their state instead of selecting it from the dropdown list.
2. The focus remains on the country field instead of the country field being hidden upon country selection.
add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );
Does anyone know how to adopt this solution while preventing the two issues above? Thanks in advance for any help.