我正在尝试将用户名添加到客户电子邮件的页脚中。 我还有其他添加用户名的代码。如下。 值得注意的是,我在子主题中使用functions.php。
add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2);
function change_admin_email_subject( $subject, $order )
{
$subject = sprintf( 'New Customer Order (# %s) from %s %s - %s', $order->id, $order->billing_first_name, $order->billing_last_name, $order->order_date );
return $subject;
}
现在这很好用,但是当我尝试对页脚使用similiar时,我只会得到错误或什么也没有。
add_action( 'woocommerce_email_footer', 'update_footer_for_emails');
function update_footer_for_emails( $email, $order )
{
$customer = $order->get_billing_first_name();
echo '<h1>' . $customer . ', please stay in touch</h1>';
}
有人能解释为什么它不起作用吗,我现在已经为此花了两天时间..
谢谢:-)
答案 0 :(得分:0)
好吧,似乎我只需通过应用以下更改就可以在页脚中解决此问题。
x3
尽管它是固定的,但我实际上不明白为什么这样做?这是因为对象已传递到页脚中,但对于其他模板,该对象已在范围内?