代码之家  ›  专栏  ›  技术社区  ›  Alan

在WooCommerce的“管理订单”列表的新列中添加客户电子邮件

  •  1
  • Alan  · 技术社区  · 6 年前

    我正在尝试找到一种方法,如何在WooCommerce订单视图的标题行中添加客户电子邮件。

    关于如何实现这一点有什么想法、建议或建议吗?

    =

    1 回复  |  直到 6 年前
        1
  •  1
  •   LoicTheAztec    6 年前

    要将用户电子邮件添加为单独的列,您将使用以下内容:

    在管理订单列表的“订单号”列后添加自定义列 添加_filter(“管理_edit-shop_order_columns”,“添加_user_email_order_column”,10,1); 函数添加用户电子邮件订购栏($columns){ $new_columns=array(); foreach($columns as$key=>$column){ $new_columns[$key]=$column; //在“order\u number”后面插入新列 如果($key=='订单号'){ $new_columns['customer_email']=uuuu(“email”,“woocommerce”); } } 返回$new_列; } //在管理订单列表中将数据显示到自定义列 添加_action(“管理_shop_order_posts_custom_column”,“显示_user_email_order_column”,10,2); 函数显示用户电子邮件订购栏($column,$post-id){ 全球美元订单; 如果($column=='客户电子邮件'){ 如果($u order->get_customer_id()){ $email=$the_order->get_billing_email();//账单电子邮件 //输出电子邮件 echo'<a href=“mailto:'.$email.''”class=“user view”><strong>'.$email.'</strong></a>'; } } } < /代码>

    代码位于活动子主题(或活动主题)的function.php文件中。测试和工作。

    代码位于活动子主题(或活动主题)的function.php文件中。测试和工作。

    enter image description here