简体   繁体   English

Woocommerce-将用户名添加到新订单电子邮件主题行

[英]Woocommerce - Add username to new order email subject line

Is it possible (and if so any help would be much appreciated) to.... 是否有可能(如果可以的话,将不胜感激)...

Add the logged in username to the 'new order' emails within woocommerce 将登录的用户名添加到woocommerce中的“新订单”电子邮件中

I can add items such as blogname, date, order number etc but need to somehow get the username on the subject line. 我可以添加诸如博客名称,日期,订单号等项目,但需要以某种方式在主题行上获取用户名。

So it would be if joe blogs is ordering 因此,如果Joe博客正在订购

Subject: New order from Joe blogs - Order number #444 主题:来自Joe博客的新订单-订单号#444

I have found some different suggestions but I have no php experience so if someone can point me to a how to guide or help further that would be great 我发现了一些不同的建议,但是我没有php经验,所以如果有人可以向我指出如何指导或进一步帮助,那将是很棒的

Thanks in advance 提前致谢

I had been looking for the same thing. 我一直在寻找相同的东西。 Hadn't quite found what I was looking for but have been able to edit someone else's coding a little bit to suit. 还没有完全找到我想要的东西,但是能够编辑其他人的编码以适应需要。 I don't know much about coding and php functions but if you are using a child theme you can just pop the below coding into the child themes function.php and it should do the trick. 我对编码和php函数了解不多,但是如果您使用的是子主题,则可以将以下编码弹出到子主题function.php中,它应该可以解决问题。

add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);

function change_admin_email_subject( $subject, $order ) {
global $woocommerce;

$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

$subject = sprintf( 'New Customer Order (# %s) from %s %s - %s', $order->id, $order->billing_first_name, $order->billing_last_name, $order->order_date );

return $subject;
}

I've also included the order date and time on mine as I thought this would be useful but if you don't think you would need/want this you can delete - %s' and '$order->order_date 我还包括了我的订购日期和时间,因为我认为这会很有用,但是如果您认为不需要/不需要,可以删除- %s' and '$order->order_date

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM