wordpress Woocommerce 新客户管理员通知电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14343928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:08:05  来源:igfitidea点击:

Woocommerce New Customer Admin Notification Email

wordpresswoocommerce

提问by BWDesign

I am building an ecommerce site using Wordpress and Woocommerce. I need the site to send out a notification email to the site administrator when a new customer account is registered. I thought this functionality would be built into Woocommerce since it uses the Wordpress user account structure and Wordpress sends new user notifications, but it doesn't appear to be. Does anyone know of a plugin or a function I can use to add this functionality? Thanks!

我正在使用 Wordpress 和 Woocommerce 构建一个电子商务网站。我需要网站在注册新客户帐户时向网站管理员发送通知电子邮件。我认为此功能将内置到 Woocommerce 中,因为它使用 Wordpress 用户帐户结构,并且 Wordpress 会发送新用户通知,但似乎并非如此。有谁知道我可以用来添加此功能的插件或函数?谢谢!

回答by danielevigi

I'm assuming that you are using html inside emails. If you are using plain text the procedure is similar.

我假设您在电子邮件中使用 html。如果您使用纯文本,则过程类似。

You need to override the woocommerce template structure. Here you can find how: http://docs.woothemes.com/document/template-structure/.

您需要覆盖 woocommerce 模板结构。您可以在这里找到方法:http: //docs.woothemes.com/document/template-structure/

Actually the only file you need to override is your_template_directory/woocommerce/emails/customer-new-account.php.

实际上,您需要覆盖的唯一文件是 your_template_directory/woocommerce/emails/customer-new-account.php。

At the end of this file add this line of code:

在此文件的末尾添加以下代码行:

<?php do_action( 'new_customer_registered', $user_login ); ?>

In functions.php add this:

在functions.php中添加:

function new_customer_registered_send_email_admin($user_login) {
  ob_start();
  do_action('woocommerce_email_header', 'New customer registered');
  $email_header = ob_get_clean();
  ob_start();
  do_action('woocommerce_email_footer');
  $email_footer = ob_get_clean();

  woocommerce_mail(
    get_bloginfo('admin_email'),
    get_bloginfo('name').' - New customer registered',
    $email_header.'<p>The user '.esc_html( $user_login ).' is registered to the website</p>'.$email_footer
  );
}
add_action('new_customer_registered', 'new_customer_registered_send_email_admin');

回答by Makarand Mane

add_action('woocommerce_created_customer', 'admin_email_on_registration', 10 , 1);
function admin_email_on_registration( $customer_id) {
    wp_new_user_notification( $customer_id );
}

woocommerce_created_customeris hook which is called when user created by woocommerce. It only sends notification to customer. we will use wp_new_user_notification() function to send notification to Admin.

woocommerce_created_customer是由 woocommerce 创建用户时调用的钩子。它只向客户发送通知。我们将使用 wp_new_user_notification() 函数向管理员发送通知。

回答by joshuaiz

I was pulling my hair out trying to figure this same issue out and after going back and forth with the developers the default is to notsend new customer registration notification emails to admin.

我正在努力解决同样的问题,在与开发人员反复讨论后,默认情况下向管理员发送新客户注册通知电子邮件。

After trying various email plugins and even resorting to using WP SMTP Email, I finally decided to leave it alone.

在尝试了各种电子邮件插件甚至诉诸使用 WP SMTP 电子邮件之后,我终于决定不理会它。

That said, WooCommerce 2.0 was released today so it may be built in the new version.

也就是说,今天发布了 WooCommerce 2.0,因此它可能会内置在新版本中。

回答by Juzz Franks

the answers is in the emails sections of "woocommerce / settings"

答案在“ woocommerce / settings”的电子邮件部分

simply change the from email to [email protected]

只需将电子邮件更改为 [email protected]

worked for me as i also had the same issues

对我来说有效,因为我也有同样的问题