Customer Email and Phone Column in the Orders List
Adds the customer's email address and phone number to the admin orders list as click-to-email and click-to-call links.
Opens WPIDE on
Code
$wpide_contact_column = function ( $columns ) {
$columns['wpide_contact'] = 'Contact';
return $columns;
};
$wpide_contact_render = function ( $column, $order ) {
if ( 'wpide_contact' !== $column ) {
return;
}
$order = $order instanceof WC_Order ? $order : wc_get_order( $order );
if ( ! $order ) {
return;
}
$email = $order->get_billing_email();
$phone = $order->get_billing_phone();
if ( $email ) {
printf( '<a href="mailto:%1$s">%2$s</a><br>', esc_attr( $email ), esc_html( $email ) );
}
if ( $phone ) {
printf( '<a href="tel:%1$s">%2$s</a>', esc_attr( preg_replace( '/[^\d+]/', '', $phone ) ), esc_html( $phone ) );
}
};
add_filter( 'manage_woocommerce_page_wc-orders_columns', $wpide_contact_column );
add_filter( 'manage_edit-shop_order_columns', $wpide_contact_column );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', $wpide_contact_render, 10, 2 );
add_action( 'manage_shop_order_posts_custom_column', $wpide_contact_render, 10, 2 );
Notes
Only staff who can view the orders screen see these details.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.