복붙노트

[WORDPRESS] Woocommerce 관리 주문 노트에 상점 관리자 사용자 이름 추가

WORDPRESS

Woocommerce 관리 주문 노트에 상점 관리자 사용자 이름 추가

해결법


  1. 1.주문 노트에 주문을 업데이트 한 상점 관리자의 사용자 이름을 추가하려면 다음을 사용 :

    주문 노트에 주문을 업데이트 한 상점 관리자의 사용자 이름을 추가하려면 다음을 사용 :

    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;
    }
    

    코드는 function.php의 활성 자식 테마의 파일 (또는 활성 테마)에 간다. 테스트 및 작품 ..

  2. from https://stackoverflow.com/questions/54734573/add-the-shop-manager-username-to-woocommerce-admin-order-notes by cc-by-sa and MIT license