Woocommerce-操作挂钩“ woocommerce_rest_insert_order_note”不触发

时间:2019-06-20 22:02:36

标签: php woocommerce action-hook

woocommerce_rest_insert_order_note操作挂钩未触发。

当订单通过REST API获得私人备忘时,我尝试自动填写Woocommerce货运跟踪,我发现在创建备忘或通过Rest API进行更新后,操作便会启动。我使用Curl通过API创建新的订单注释,但是创建注释时挂钩不会触发。任何对此都有经验的人请帮助我!

add_action( 'woocommerce_rest_insert_order_note', 'action_woocommerce_rest_insert_order_note', 10, 3 );
// define the woocommerce_rest_insert_order_note callback
function action_woocommerce_rest_insert_order_note( $note, $request, $true ) {
    //if ($_SERVER['REQUEST_METHOD'] !== 'POST') return;
    if (strstr($note->comment_content, 'shipped') !== false) {
        //$order = wc_get_order( (int) $request['order_id'] );
        $order->update_status('completed');
    }
}

我希望通过API创建注释时它可以工作,但似乎不起作用,如果我只写一点代码:$ order-> update_status('completed'); 非常感谢您的帮助!

0 个答案:

没有答案
相关问题