作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 WooCommerce 在 Wordpress 上开发电子商务网站。我想在订单确认页面(即付款后)检索并显示客户在结账时选择的“运输方式”(即交付或收集等)。
我正在尝试使用 get_post_meta($post_id, $key, $single)
来做到这一点功能。我无法这样做,因为我不知道 $key 值。
我尝试了以下代码(在 php 标签内):
echo get_post_meta( $order_id, 'shipping_method', true );
$key
.
最佳答案
从 WooCommerce 3 开始,如果您想获得运输格式的方法标题,最好使用 WC_Order
方法 get_shipping_method()
喜欢:
// Get the WC_Order object from the Order ID
$order = wc_get_order( $order_id );
// Output the shipping method(s) formatted method title(s)
echo $order->get_shipping_method();
关于php - 如何在 WooCommerce 中检索订单的运输方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57444694/
我是一名优秀的程序员,十分优秀!