答案 0 :(得分:1)
要将用户电子邮件添加为单独的列,您将使用以下内容:
// Add custom column after "Order number" column in admin orders list
add_filter('manage_edit-shop_order_columns', 'add_user_email_order_column', 10, 1 );
function add_user_email_order_column( $columns ) {
$new_columns = array();
foreach ($columns as $key => $column ){
$new_columns[$key] = $column;
// Insert the new column after 'order_number'
if( $key === 'order_number'){
$new_columns['customer_email'] = __("Email", "woocommerce");
}
}
return $new_columns;
}
// Display data to custom column in admin orders list
add_action( 'manage_shop_order_posts_custom_column' , 'display_user_email_order_column', 10, 2 );
function display_user_email_order_column( $column, $post_id ) {
global $the_order;
if( $column === 'customer_email' ) {
if( $the_order->get_customer_id() ){
$email = $the_order->get_billing_email(); // Billing email
// Outpup the email
echo '<a href="mailto:'.$email.'" class="user-view"><strong>'.$email.'</strong></a>';
}
}
}
代码进入您的活动子主题(或活动主题)的function.php文件中。经过测试,可以正常工作。