问题
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
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
Subject: New order from Joe blogs - Order number #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
Thanks in advance
回答1:
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;
}
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
I hope this helps.
来源:https://stackoverflow.com/questions/22484385/woocommerce-add-username-to-new-order-email-subject-line