我试图通过以下方式覆盖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');
此代码用于向网站管理员发送电子邮件。通过get_bloginfo
函数检索admin_email。但是,我正在尝试将电子邮件发送给商店经理。知道在这种情况下应该使用什么功能或代码吗?
另一种选择是将以下代码添加到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' );
}
答案 0 :(得分:0)
如下解决。我在functions.php
文件中添加了以下代码:
/* SEND NEW CUSTOMER EMAIL TO KILIKILI */
/* --- */
add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
if ($object == 'customer_new_account') {
$headers .= 'BCC: Store manager name <storemanager@domain.com>' . "\r\n";
}
return $headers;
}