Woocommerce-将用户名添加到新订单电子邮件主题行 [英] Woocommerce - Add username to new order email subject line
问题描述
是否有可能(如果可以的话,将不胜感激)....
Is it possible (and if so any help would be much appreciated) to....
将登录的用户名添加到woocommerce中的新订单"电子邮件中
Add the logged in username to the 'new order' emails within woocommerce
我可以添加诸如博客名称,日期,订单号等项目,但需要以某种方式在主题行上获取用户名.
I can add items such as blogname, date, order number etc but need to somehow get the username on the subject line.
如果乔博客正在订购
主题:来自Joe博客的新订单-订单号#444
Subject: New order from Joe blogs - Order number #444
我发现了一些不同的建议,但是我没有php经验,所以如果有人可以向我指出如何指导或进一步帮助,那就太好了
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函数了解不多,但是如果您使用的是子主题,则可以将下面的编码弹出到子主题function.php中,它应该可以解决问题.
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.
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;
}
我还提供了我的订购日期和时间,因为我认为这会很有用,但是如果您认为不需要/不需要,可以删除-%s'和'$ order-> order_date
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
我希望这会有所帮助.
这篇关于Woocommerce-将用户名添加到新订单电子邮件主题行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!