admin管理员组

文章数量:1393116

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'.

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?

Notes:

  • WordPress 5.3.2
  • WooCommerce 4.0.1

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'.

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?

Notes:

  • WordPress 5.3.2
  • WooCommerce 4.0.1
Share Improve this question edited Mar 25, 2020 at 0:54 Damon Hill asked Mar 25, 2020 at 0:47 Damon HillDamon Hill 158 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

go to Woocommerce -> Settings -> Shipping -> Shipping options and change the Shipping destination options

本文标签: customizationHow to customize shipping regionstates on WooCommerce