0

我是 Woocommerce 的新手,我试图在电子邮件的开头显示客户的姓名。

所以电子邮件看起来像这样:

[HEADER]您的订单已下达[/HEADER]

[H2]嗨{CUSTOMER_NAME}[/H2]

[P]一些文字[/P]

[邮件的其余部分]

我尝试在我的主题中将类似的内容添加到 functions.php 中。

//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>';

    }

}

但这不起作用。有人可以帮忙吗?

4

2 回答 2

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>';
}
于 2017-05-16T10:45:35.370 回答
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 片段

于 2017-05-16T12:08:47.477 回答