• Resolved muhammadnan

    (@muhammadnan)


    /wp-admin/admin.php?page=wc-admin&path=%2Fanalytics%2Forders

    On report in above link, there is only first name of user, I want “Email” field instead of first name. How can be this possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @muhammadnan

    It is possible to customize the columns shown in the orders report in WooCommerce by using a filter hook in WordPress.

    To add the email column to the orders report, you can use the following code snippet:

    add_filter( 'manage_edit-shop_order_columns', 'add_email_column_to_orders' );
    function add_email_column_to_orders( $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_email'] = __( 'Email', 'woocommerce' );
           }
       }
       return $new_columns;
    }
    
    add_action( 'manage_shop_order_posts_custom_column', 'add_email_data_to_orders', 2 );
    function add_email_data_to_orders( $column ) {
       global $post;
       if ( 'order_email' === $column ) {
           $order = wc_get_order( $post->ID );
           echo esc_html( $order->get_billing_email() );
       }
    }

    This code will add a new column to the orders report called “Email” and display the email address of the user who placed the order in that column. You can add this code to your WordPress site by adding it to your child theme’s functions.php file or creating a custom plugin.

    I hope this helps! Let me know if you have any questions.

    Thread Starter muhammadnan

    (@muhammadnan)

    Thank you. but this ads email on the orders page. I need emails on analytics page

    /wp-admin/admin.php?page=wc-admin&path=%2Fanalytics%2Forders

    Hi @muhammadnan

    Thanks for reaching out!

    I understand that you want to display the customer’s email address under Analytics > Orders.

    These forums are meant for general support with the core functionality of WooCommerce itself. What you want to achieve is a bit complex and would require customization to do it. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

    Hi @muhammadnan

    To add the email column to the orders report on the WooCommerce analytics page, you can use the following code snippet:

    add_filter( 'woocommerce_admin_report_column_names', 'add_email_column_to_analytics_orders', 10, 1 );
    function add_email_column_to_analytics_orders( $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_email'] = __( 'Email', 'woocommerce' );
           }
       }
       return $new_columns;
    }
    
    add_action( 'woocommerce_admin_report_column_order_data', 'add_email_data_to_analytics_orders', 10, 3 );
    function add_email_data_to_analytics_orders( $column, $order ) {
       if ( 'order_email' === $column ) {
           echo esc_html( $order->get_billing_email() );
       }
    }

    This code will add a new column to the orders report on the WooCommerce analytics page called “Email” and display the email address of the user who placed the order in that column.

    I hope this helps! Let me know if you have any questions.

    Thread Starter muhammadnan

    (@muhammadnan)

    Thank you @faisalahammad . But it seems it’s not working, nothing happened on the analytics > order page view.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding email field in orders report’ is closed to new replies.