admin管理员组文章数量:1435859
I need to be able to send the admin email for a new order also to the e-mail address linked to the current logged in user.
This is required as 1 account is for different people (people who give a present), but the originally created account is still linked to the original user e-mail address (from the parents).
This way, parents are notified via email when a new gift is given.
I don't seem to find the fix here. I started to adapt the code from Adding a second email address to a completed order in WooCommerce, but now I want to dynamically add the e-mail address of the user.
Any ideas what I'm doing wrong here?
/* SEND ADMIN E-MAIL TO LOGGED IN USER */
/* --- */
add_filter( 'woocommerce_email_recipient_new_order', 'your_email_recipient_filter_function', 10, 2);
/* Add parents e-mail address to new order admin mail */
function your_email_recipient_filter_function($recipient, $object) {
$user_info = get_userdata($order->user_id);
$recipient = $recipient . ', ' . $user_info->user_email;
return $recipient;
}
I need to be able to send the admin email for a new order also to the e-mail address linked to the current logged in user.
This is required as 1 account is for different people (people who give a present), but the originally created account is still linked to the original user e-mail address (from the parents).
This way, parents are notified via email when a new gift is given.
I don't seem to find the fix here. I started to adapt the code from Adding a second email address to a completed order in WooCommerce, but now I want to dynamically add the e-mail address of the user.
Any ideas what I'm doing wrong here?
/* SEND ADMIN E-MAIL TO LOGGED IN USER */
/* --- */
add_filter( 'woocommerce_email_recipient_new_order', 'your_email_recipient_filter_function', 10, 2);
/* Add parents e-mail address to new order admin mail */
function your_email_recipient_filter_function($recipient, $object) {
$user_info = get_userdata($order->user_id);
$recipient = $recipient . ', ' . $user_info->user_email;
return $recipient;
}
Share
Improve this question
edited Mar 20, 2019 at 12:51
butlerblog
5,1313 gold badges28 silver badges44 bronze badges
asked Mar 20, 2019 at 11:42
BarrieOBarrieO
992 silver badges12 bronze badges
1 Answer
Reset to default 1What you have makes sense, except that your variable names dont match. You have $object in your function definition and in the function code you are trying to use $order.
Adjusted:
/* SEND ADMIN E-MAIL TO LOGGED IN USER */
/* --- */
add_filter( 'woocommerce_email_recipient_new_order', 'your_email_recipient_filter_function', 10, 2);
/* Add parents e-mail address to new order admin mail */
function your_email_recipient_filter_function($recipient, $order) {
$user_info = get_userdata($order->user_id);
$recipient = $recipient . ', ' . $user_info->user_email;
return $recipient;
}
本文标签: woocommerce offtopicSend admin new order email to logged in user as well
版权声明:本文标题:woocommerce offtopic - Send admin new order email to logged in user as well 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745672636a2669663.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论