How to customize shipping region/states on WooCommerce


I added 3 States (they’re regions, in fact) using this snippet (in functions.php file):

 * Adds States
add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {

  $states['UY'] = array(
    'UY1' => 'La Barra', 
    'UY2' => 'Punta del Este',
    'UY3' => 'Maldonado'

  return $states;

And I added a couple of shipping methods for each new ‘State’.

enter image description here

The problem is when selecting the shipping address on the checkout, it doesn’t show the corresponding shipping methods available. E.g. ‘Maldonado’ It only shows the correct shipping methods if I enter ‘UY3’

I tried changing UY3 for Maldonado too, like this:

$states['UY'] = array(
    'La Barra' => 'La Barra', 
    'Punta del Este' => 'Punta del Este',
    'Maldonado' => 'Maldonado'

but it doesn’t work either. I assume that the 2 characters country code is required.

How can I make it work so the customers could insert the State name for the shipping methods to show?


  • WordPress 5.3.2
  • WooCommerce 4.0.1
, Damon Hill 3 years 2020-03-24T20:51:22-05:00 0 Answers 115 views 0

Leave an answer