我是Woocommerce的新手,我正试图在电子邮件的开头显示客户的姓名。
所以电子邮件看起来像这样:
[HEADER]您的订单已被放置[/ HEADER]
[H2]您好{CUSTOMER_NAME} [/ H2]
[P]一些文字[/ P]
[邮件的其余部分]
我尝试在我的主题中添加类似这样的东西。
//add the first name of the person to the email.
add_filter('woocommerce_email_order_details','name_to_processing_customer_email', 10, 3);
function name_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 '<h2>Hej '.$order->billing_first_name .'</h2>';
}
}
但这不起作用。 有人可以帮忙吗?
答案 0 :(得分:1)
试试这个::
add_filter('woocommerce_email_order_details','name_to_processing_customer_email', 10, 3);
function name_to_processing_customer_email( $order_id, $sent_to_admin, $plain_text, $email ) {
$order = new WC_Order( $order_id );
echo '<h2>Hej '.$order->billing_first_name .' '.$order->billing_last_name.'</h2>';
}
答案 1 :(得分:0)
add_action( 'woocommerce_email_after_order_table', 'name_to_processing_customer_email', 10, 2 );
function name_to_processing_customer_email( $order, $is_admin_email ) {
echo '<p><h4>Shipping:</h4> ' . $order->get_billing_first_name() . '</p>';
}
检查此WC3代码段