[英]Add account email conditionally on Customer processing Order email notification in Woocommerce
[英]Add customer email address to new account email notification in WooCommerce
我想在“新帐户”电子邮件中插入客户电子邮件地址。
到目前为止,我尝试在钩子中使用$user_email
而不是$user_login
和$order->billing_email
,但每次都显示空白。
更新:您可以使用挂钩在woocommerce_email_header
动作钩子中的自定义函数:
add_action( 'woocommerce_email_header', 'add_customer_billing_email', 20, 2 );
function add_customer_billing_email( $email_heading, $email )
{
// Only for "Customer new account" email notifications
if( $email->id != 'customer_new_account' ) return;
// Get user billing email
global $user_login;
$user = get_user_by('login', $user_login );
$email = $user->billing_email;
// HTML Output
echo '<p>'.__('Billing email').': <a href="mailto:'.$email.'">'.$email.'</a></p>';
}
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中。
经过测试和工作。
或者您可以在模板中插入emails/customer-new-account.php
以下代码,在您选择的位置:
<?php
// Get user billing email
$user = get_user_by('login', $user_login );
$email = $user->billing_email;
// HTML Output
echo '<p>'.__('Billing email').': <a href="mailto:'.$email.'">'.$email.'</a></p>';
?>
经过测试和工作。
官方文档: 通过主题覆盖WooCommerce模板
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.