【发布时间】:2019-04-15 10:08:13
【问题描述】:
如何在这封电子邮件的主题行中添加产品名称。是否有电子邮件主题行的可用过滤器列表?我希望能够做到这一点而不必编写自定义 php。我想做这样的事情:
已完成订单 - [{product_name}] ({order_number}) - {order_date}
以下代码在functions.php 中尝试并添加,但未显示主题:
add_filter( 'woocommerce_email_subject_customer_completed_order', 'customer_completed_order_subject', 10, 2 );
function customer_completed_order_subject($string,$order){
$fname = $order->billing_first_name;
$lanme = $order->billing_last_name;
$email = $order->billing_email;
$items = $order->get_items();
foreach($items as $meta_key => $items){
$product_name = $items['name'];
$product_id = $items['product_id'];
}
$subject_line = get_field('email_subject',$product_id);
$subject_line = str_replace('{product}',$product_name,$subject_line);
$subject_line = str_replace('{biller_fname}',$fname,$subject_line);
$subject_line = str_replace('{biller_lastname}',$lanme,$subject_line);
$subject_line = str_replace('{biller_email}',$email,$subject_line);
$subject_line = str_replace('{blog_name}',get_bloginfo('name'),$subject_line);
return $subject_line;
}
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce email-notifications