Thêm cột phương thức thanh toán trong admin WooCommerce

Để có cái nhìn tổng quan khi khách hàng order đơn hàng trên website của bạn bạn có thể sử dụng code phía dưới add vào file functions.php hoặc cài plugin Code Snippets để thêm cũng được nhé.

Thêm cột phương thức thanh toán trong admin orders list WooCommerce đơn hàng như sau:

add_filter( 'manage_edit-shop_order_columns', 'add_payment_method_custom_column', 20 );
    function add_payment_method_custom_column( $columns ) {
     $new_columns = array();
     foreach ( $columns as $column_name => $column_info ) {
     $new_columns[ $column_name ] = $column_info;
     if ( 'order_total' === $column_name ) {
     $new_columns['order_payment'] = __( 'Payment Method', 'my-textdomain' );
     }
     }
     return $new_columns;
    }
    add_action( 'manage_shop_order_posts_custom_column', 'add_payment_method_custom_column_content' );
    function add_payment_method_custom_column_content( $column ) {
     global $post;
     if ( 'order_payment' === $column ) {
     $order = wc_get_order( $post->ID );
     echo $order->payment_method_title;
     }
 }

Thêm vào xong bạn lưu lại và sẽ thấy kết quả như hình trên.

Nếu bạn thấy bài viết có ích hãy sao chép link và chia sẻ bài viết
user

Yêu thích Võ thuật và Công nghệ thông tin, thích viết và chia sẽ về 2 lĩnh vực này thế thôi :D

Bài viết liên quan