向woocommerce中的页脚消息中添加账单者姓名
我正在尝试将用户名添加到客户电子邮件的页脚。 我有其他添加用户名的代码。如下。 值得注意的是,我在子主题中使用functions.php向woocommerce中的页脚消息中添加账单者姓名,woocommerce,hook-woocommerce,Woocommerce,Hook Woocommerce,我正在尝试将用户名添加到客户电子邮件的页脚。 我有其他添加用户名的代码。如下。 值得注意的是,我在子主题中使用functions.php add_filter('woocommerce_email_subject_new_order', 'change_admin_email_subject', 1, 2); function change_admin_email_subject( $subject, $order ) { $subject = s
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>';
}
add_action('woocommerce_email_footer','update_footer_for_email');
功能更新\u页脚\u用于电子邮件($email,$order)
{
$customer=$order->get_billing_first_name();
回音“.$customer.”,请保持联系;
}
有人能解释为什么这不起作用吗?我已经为此伤了两天的脑筋
谢谢:-)看来我在页脚中通过简单地应用以下更改解决了这个问题
// function to add a keep in touch note, as well as facebook and insta icons to emails
add_action( 'woocommerce_email_footer', 'update_footer_for_emails');
function update_footer_for_emails( $order )
{
$user_id = $order->object->get_billing_first_name();
$order_id = $order->object->id;
$email_greeting = sprintf( '<h1>Hi %s, please stay in touch</h1>', $user_id );
}
//在电子邮件中添加保持联系便笺以及facebook和insta图标的功能
添加_操作('woocommerce_email_footer'、'update_footer_for_email');
功能更新\u电子邮件的页脚\u($order)
{
$user_id=$order->object->get_billing_first_name();
$order\u id=$order->object->id;
$email\u greeting=sprintf('Hi%s,请保持联系',$user\u id);
}
虽然它是固定的,但我真的不明白为什么会这样?这是因为对象已传递到页脚,但对于其他模板,对象已在范围内吗