Enable shipping state field for specific countries during WooCommerce Checkout

During WooCommerce checkout, there are number of countries (Afghanistan, Poland, etc ) for which state field does not show up while entering billing and shipping address.
The complete list of states can be found by referring the function “load_country_states” from WooCommerce code class-wc-countries.php.
Now, if you want to enable state field for some reason, what should you do? WooCommerce doesn’t provide an option in settings to achieve this.
Below code snippet will help you to solve this problem.

Code Snippet to enable State for specific countries.

Below code snippet will enable state for Afghanistan (‘AF’). Change the code accordingly to so the same for other countries.

Paste this snippet to your theme’s functions.php file to make it work.

Screenshot

Screen Shot 2016-05-26 at 8.39.12 PM

Leave a Reply