Last active
February 24, 2021 10:02
-
-
Save rwkyyy/a138c27bcbaccac631fe6282f0ecc29c to your computer and use it in GitHub Desktop.
Show the order phone number in the woocommerce order list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add the column, we need to display it, right? | |
function wc_order_extras_column_evd( $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_phone'] = __( 'Phone no.', 'rwky_ro' ); | |
} | |
} | |
return $new_columns; | |
} | |
add_filter( 'manage_edit-shop_order_columns', 'wc_order_extras_column_evd', 20 ); | |
// let's fill the column with data | |
function wc_order_extras_evd( $column ) { | |
global $post; | |
if ( 'order_phone' === $column ) { | |
$order = wc_get_order( $post->ID ); | |
$order_data = $order->get_data(); // The Order data | |
$client_phone_no = $order_data['billing']['phone']; | |
echo $client_phone_no; | |
} | |
} | |
add_action( 'manage_shop_order_posts_custom_column', 'wc_order_extras_evd' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment