dtf76989 2015-03-31 21:24
浏览 128
已采纳

WooCommerce将订单送货地址作为单独的字段

I'm building a WooCommerce plugin which sends orders to a 3rd party api.

However, I have found there isn't a way to get the individual fields/properties of the order shipping address since WooCommerce v2.3. The only function available is

get_formatted_shipping_address()

Which returns a string and it seems the function which returns an address array "get_shipping_address()" has been Deprecated in version 2.3.

Does anyone know a way to get the shipping address as an array for an order? I don't really want to resort to using an old version of WooCommerce. Perhaps there is a hook, action or class override I can use to achieve this?

  • 写回答

3条回答 默认 最新

  • duanli5662 2017-06-18 18:04
    关注

    I got the shipping address in this simple way :

    function get_shipping_zone(){     
    
    global $woocommerce;
    $customer = new WC_Customer();
    $post_code = $woocommerce->customer->get_shipping_postcode();
    $zone_postcode = $woocommerce->customer->get_shipping_postcode();
    $zone_city =get_shipping_city(); 
    $zone_state = get_shipping_state(); 
    
    }
    

    You can also print_r for the "$woocommerce->customer" you will get the all meta data you may need, it is very useful to know it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图