【发布时间】:2018-03-14 11:16:28
【问题描述】:
我只想知道如果订单具有特定类别(例如(预购)),是否可以更改电子邮件主题。我想将 PO 放在开头(PO 新客户订单 #0000),然后客户收到的所有其他订单都会收到默认电子邮件主题(新客户订单 #0000)。
add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);
function change_admin_email_subject( $subject, $order ) {
global $woocommerce;
global $product;
if ( has_term( 'preorder', $product->ID ) ) {
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$subject = sprintf( '[%s]New customer order (# %s) from %s %s', $blogname, $order->id, $order->billing_first_name, $order->billing_last_name );
}
return $subject;
}
注意:我只是将这段代码复制到某个地方。
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications