最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - How to customize shipping regionstates on WooCommerce

programmeradmin3浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论