【问题标题】:How to find the states/cities of any country in WooCommerce如何在 WooCommerce 中查找任何国家/地区的州/城市
【发布时间】:2021-07-12 02:19:41
【问题描述】:

我知道按照下面的方法我可以在woocommerce中获取国家:

global $woocommerce;
$woocommerce->customer->get_shipping_country()

WC()->customer->get_shipping_country()

但我想知道如何找到任何国家/地区的州/城市。

【问题讨论】:

    标签: php wordpress woocommerce location country


    【解决方案1】:

    在 WooCommerce 中,您只能使用以下方式获取某个国家/地区的州(或地区):

    $country_code = WC()->customer->get_shipping_country();
    
    $states_array = WC()->countries->get_states( $country_code ); // States array for a country
    

    您可以通过WC()->customer->get_shipping_state(); 获取客户发货状态。
    您可以通过WC()->customer->get_shipping_city();获取客户发货城市。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-10
      • 2017-10-20
      • 2011-01-14
      • 1970-01-01
      • 2017-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多