在Woocommerce管理订单编辑页面中以编程方式添加自定义订单

Max*_*Max 6 php wordpress backend orders woocommerce

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

任何帮助将不胜感激.

订单管理页面中的WooCommerce订单备注

Loi*_*tec 21

从动态订单ID中,您可以通过WC_Order add_order_note()以下方式使用方法:

// 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 );
Run Code Online (Sandbox Code Playgroud)

经过测试和工作.

  • 我不需要保存订单。它在 add_order_note() 中处理; (3认同)