Add the Shop Manager username to Woocommerce Admin Order notes

前端 未结 1 562
别跟我提以往
别跟我提以往 2020-12-18 14:37

I have a problem right now. I have a plugin that allows me to quickly change the status of my orders from the admin order list. Unfortunately the name of the shop manager is

相关标签:
1条回答
  • 2020-12-18 15:13

    To add the username of the shop manager that has updated the Order to the order note, use the following:

    add_filter( 'woocommerce_new_order_note_data', 'filter_woocommerce_new_order_note_data', 10, 2 );
    function filter_woocommerce_new_order_note_data( $args, $args2 ) {
        if( ! $args2['is_customer_note'] && is_user_logged_in() && current_user_can( 'edit_shop_order', $args2['order_id'] ) ){
            $user = get_user_by( 'id', get_current_user_id() );
            $args['comment_author'] = $user->display_name;
            $args['comment_author_email'] = $user->user_email;
        }
    
        return $args;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works..

    0 讨论(0)
提交回复
热议问题