2017-05-09 14 views
0

私はWoocommerceを初めて使いました。メールの冒頭に顧客の名前を表示しようとしています。woocommerceの電子メールテンプレートに顧客名を表示するにはどうすればいいですか?

だから、電子メールは次のようになります:

[HEADER]あなたが配置された注文[/ HEADER]

[H2]こんにちは{CUSTOMER_NAME} [/ H2]

[P]いくつかのテキスト[/ P]

【メールREST]

私はこのようなものを私のテーマの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>'; 

    } 

} 

しかし、これは機能しません。 誰かを助けることができますか?

答えて

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>'; 
} 
+0

それは動作します。ただし、配置が正しくありません。テキストは注文アイテムのすぐ上に表示され、メールヘッダーの直後になりたい。 –

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が

0

は、あなたがこの問題を修正しましたスニペット?試してみてください私は同じ、 "こんにちは"が表示されているが、間違った場所です。私はヘッダーの後に置いておきたいと思います...

+0

これは質問のコメントであり、答えではありません。投稿する前に、SOのガイドラインをお読みください。 – sparkplug

関連する問題