Customer phone in the orders list
Adds a Phone column to the WooCommerce orders list, so you can call a customer without opening the order.
<?php
$snipfire_add_column = static function ( $columns ) {
$columns['snipfire_phone'] = __( 'Phone', 'woocommerce' );
return $columns;
};
$snipfire_show_phone = static function ( $column, $order ) {
if ( 'snipfire_phone' !== $column ) {
return;
}
$order = $order instanceof WC_Order ? $order : wc_get_order( $order );
$phone = $order ? $order->get_billing_phone() : '';
echo $phone ? '<a href="' . esc_url( 'tel:' . preg_replace( '/[^0-9+]/', '', $phone ) ) . '">' . esc_html( $phone ) . '</a>' : '—';
};
// Orders stored in their own tables (the default) and the older posts storage.
add_filter( 'manage_woocommerce_page_wc-orders_columns', $snipfire_add_column );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', $snipfire_show_phone, 10, 2 );
add_filter( 'manage_edit-shop_order_columns', $snipfire_add_column );
add_action( 'manage_shop_order_posts_custom_column', $snipfire_show_phone, 10, 2 );
In these packs
- WooCommerce: account, emails and admin: A leaner My account page, handier order lists and emails, and lighter pages.