2016-07-28 6 views
2

購入の通知として顧客に電子メールを送信するためのカスタムWooCommerceメーラー機能がありましたが、reply-toタグを追加する必要があります。

詳細を説明すると、お客様は注文通知のメールを[email protected]から取得し、[email protected]の返信先タグを追加する必要があります。これは何

は、電子メールが[email protected]から送信されるということですが、彼らは私たちにどんな質問をしたい時に顧客が回答を打ったとき、これらの回答が[email protected]

に行きますいずれかが$mailer->sendを変更する方法を手伝ってくれる機能は、要件を達成するために?

function my_awesome_publication_notification($order_id, $checkout=null) { 
    global $woocommerce; 
    $order = new WC_Order($order_id); 
    if($order->status === 'completed') { 
     // Create a mailer 
     $mailer = $woocommerce->mailer(); 

     $message_body = __('Hello world!!!'); 

     $message = $mailer->wrap_message(
     // Message head and message body. 
     sprintf(__('Order %s received'), $order->get_order_number()), $message_body); 


     // Client email, email subject and message. 
    $mailer->send($order->billing_email, sprintf(__('Order %s received'), $order->get_order_number()), $message); 
    } 

    } 
} 
+0

:それはあなたに非常によく似ていて...、最後の参照コードに

参考文献を見てみてください。 'get_headers()'の中にありますあなたの電子メールはそこに隠れていると思います。もしそうなら、これは役に立つかもしれません:http://wordpress.stackexchange.com/questions/183206/adding-reply-to-in-the-email#answer-183224 –

+0

あなたは['woocommerce_email_headers']のフィルタリングを試みましたか( https://github.com/woothemes/woocommerce/blob/f8db1c403fd81b18958b675421ee9fc012fa6551/includes/emails/class-wc-email.php#L281)? – helgatheviking

答えて

3

追加互換性のためのWoocommerce 3+

()関数は、あなたが持っているセンドでClass WC_Emailを見て:あなたのコードにこれをトランスポーズ

send(string $to, string $subject, string $message, string $headers, string $attachments) 

、$ヘッダができましたこの方法で使用してください:

function my_awesome_publication_notification($order_id, $checkout=null) { 
    global $woocommerce; 

    // Get order object. 
    $order = new WC_Order($order_id); 

    $order_status = method_exists($order, 'get_status') ? $order->get_status() : $order->status; 

    if($order_status === 'completed') { 

     // Create a mailer 
     $mailer = $woocommerce->mailer(); 

     $message_body = __('Hello world!!!'); 

     // Message head and message body. 
     $message = $mailer->wrap_message(sprintf(__('Order %s received'), $order->get_order_number()), $message_body); 

     // Here is your header 
     $reply_to_email = '[email protected]'; 
     $headers = array(sprintf('Reply-To: %s', $reply_to_email)); 
     // Or instead, try this in case: 
     // $headers = 'Reply-To: ' . $reply_to_email . '\r\n'; 

     // Client email, email subject and message (+ header "reply to"). 
     $mailer->send($order->billing_email, sprintf(__('Order %s received'), $order->get_order_number()), $message, $headers); 
    } 
} 

これは動作するはずです。何をチェックしてみ

関連する問題