在Woocommerce中显示客户订单注释(客户注释)


Display Customer order comments (customer note) in Woocommerce

当我尝试显示woocommerce客户订单评论(不是注释,而是客户可以在结帐过程中添加的评论)时,我遇到了一个小问题。

(我将只为此问题添加相对行,因为其他 woocommerce 数据已正确显示,因此它不应该是设置问题)。

到目前为止,我尝试的是:

$notes = $order->get_customer_order_notes(); //This line returns an Array[]

在该数组中,这是我认为我需要的字段,因为它包含我的订单注释:

$notes
  0={stdClass} 38
    post_excerpt = "test"

所以我所做的是尝试像这样显示这个值:

echo "Order Notes: " . $notes->post_excerpt

但不幸的是,结果是空的。

我做错了什么?非常感谢

更新 2017 - 2018 |对于伍商务3+

从 WooCommerce 3 开始,您无法再从 WC_Order 对象访问属性。您需要改用WC_Order方法get_customer_note()

$customer_note = $order->get_customer_note();

相关:
在Woocommerce电子邮件通知
中显示订单客户备注将订单客户备注添加到YITH WoocommercePDF发票

我找到了一种显示客户结帐评论的方法,选择$order->customer_message;,然后将此值设置为变量。