在Woocommerce管理员订单编辑页面中以编程方式添加自定义订单注释 [英] Add a custom order note programmatically in Woocommerce admin order edit pages

查看:126
本文介绍了在Woocommerce管理员订单编辑页面中以编程方式添加自定义订单注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在woocommerce中,我试图通过php(以编程方式)在管理订单编辑页面中添加自定义订单注释.我还没找到路.

In woocommerce I am trying to add a custom order note in the admin order edit pages through php (so programmatically). I haven't find the way yet.

任何帮助将不胜感激.

推荐答案

从动态订单ID中,您可以使用WC_Order

From a dynamic Order Id you can use WC_Order add_order_note() method this way:

// If you don't have the WC_Order object (from a dynamic $order_id)
$order = wc_get_order(  $order_id );

// The text for the note
$note = __("This is my note's text…");

// Add the note
$order->add_order_note( $note );

经过测试,可以正常工作.

Tested and works.

这篇关于在Woocommerce管理员订单编辑页面中以编程方式添加自定义订单注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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