【发布时间】:2018-09-13 06:39:12
【问题描述】:
选项 1
我正在尝试通过以下方式覆盖 Woocommerce 模板结构: http://docs.woothemes.com/document/template-structure/.
我要覆盖的文件是:your_template_directory/woocommerce/emails/customer-new-account.php。
在这个文件的最后我添加了以下代码:
<?php do_action( 'new_customer_registered', $user_login ); ?>
In functions.php add this:
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');
此代码用于向网站管理员发送电子邮件。 admin_email 由get_bloginfo 函数检索。但是,我正在尝试将电子邮件发送给 商店经理。知道在这种情况下应该使用什么函数或代码吗?
选项 2
另一种选择是将以下代码添加到functions.php文件并对其进行调整,以便它向商店经理而不是管理员发送通知:
/**
* Notify admin when a new customer account is created
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
}
【问题讨论】:
标签: php wordpress woocommerce