我如何访问当前的 woocommerce 订单运输方式 ID? [英] How can i access current woocommerce order shipping method id?

查看:34
本文介绍了我如何访问当前的 woocommerce 订单运输方式 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了方法

$order->get_shipping_method() 

访问名称,但我想检索 id 而不是名称?

to access the name, but i want to retrieve the id instead of name?

推荐答案

我想如果有人遇到和我一样的问题,我会分享我是如何解决这个问题的.我在 $order 变量中有 WC_Order.

thought i'd share how I solved this if someone runs into the same problem as me. I have WC_Order in the $order variable.

$order->get_items( 'shipping' );

这给了我一个包含名称、类型、method_id、成本和税收的数组.

This gives me an array with name, type, method_id, cost and taxes.

这篇关于我如何访问当前的 woocommerce 订单运输方式 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆