2017-01-04 45 views
1

我对WordPress非常陌生,并创建了一个使用WooCommerce的电子商务商店。在WooCommerce中定制客户处理电子邮件通知

客户下订单后,我收到一封电子邮件,客户收到一封电子邮件 - 一封给我说他们已经订购的东西,一封给他们作为感谢电子邮件。

在此谢谢你的电子邮件,在我functions.php文件,我已经学会了改变标题的主题,包括他们的名字像这样:

//add the first name of the person to the person getting the reciept in the subject of the email. 
add_filter('woocommerce_email_subject_customer_processing_order','UEBC_change_processing_email_subject', 10, 2); 

function UEBC_change_processing_email_subject($subject, $order) { 
global $woocommerce; 
$subject = 'Thanks for your ' . get_bloginfo('name', 'display') . ' Order, '.$order->billing_first_name .'!'; 
return $subject; 
} 

中的代码片段工作正常,并只显示给客户,而不是我。例如“谢谢你的订单ABCD衣服订购约翰!”。 在电子邮件的正文中,我试图让这个个人作为一个小感谢你的消息,但是,当我做了消息,我现在用的钩:

add_action('woocommerce_email_before_order_table', 'custom_add_content', 20,1); 

我知道,因为即时通讯使用woocommerce_email_before_order_table挂钩,自定义功能将发送到客户和我自己的电子邮件正文中。

我在想,Woocommerce是否提供了一个钩子,以便自定义函数只会发送给电子邮件正文中的客户?

例如:woocommerce_email_header_customer_processing_order或单词是否有这种效果?

感谢

回答

2

添加使用woocommerce_email_before_order_table钩和定位只是客户“处理订单”电子邮件通知一些自定义的内容,你应该试试这个:

add_action('woocommerce_email_before_order_table', 'custom_content_to_processing_customer_email', 10, 4); 
function custom_content_to_processing_customer_email($order, $sent_to_admin, $plain_text, $email) { 

    if('customer_processing_order' == $email->id){ 

     // Set here as you want your custom content (for customers and email notification related to processing orders only) 
     echo '<p class="some-class">Here goes your custom content… </p>'; 

    } 

} 

代码放在功能。你活跃的孩子主题(或主题)的PHP文件。或者也可以在任何插件php文件中使用。

这段代码经过测试和工作

+0

辉煌,谢谢你的工作。出于好奇,当仅使用$ email时,将这4个参数包含在函数中的目的是什么? –

+1

由于'$ email'是第四个也是最后一个参数,所以你**不能删除其他的**,你将来可能需要添加更多的条件或基于其他参数的代码(尤其是第一个)...最重要的是,这是为你工作,还是不是? – LoicTheAztec

相关问题