2017-10-10 76 views
0

我想在woocommerce發送訂單後發送額外的電子郵件,我想我正在使用錯誤的操作/掛鉤。我哪裏錯了?如何在提交訂單後發送額外的電子郵件(Woocommerce)?

function email_processing_notification($order_id) { 

    $order = wc_get_order($order_id); 

    // load the mailer class 
    $mailer = WC()->mailer(); 

    $recipient = '***@gmail.com'; 
    $subject = __('Some Subject', 'test'); 
    $content = get_processing_notification_content($order, $subject, $mailer); 
    $headers = "Content-Type: text/html\r\n"; 

    $mailer->send($recipient, $subject, $content, $headers); 

} 

add_action('woocommerce_order_status_pending_to_processing_notification', 'email_processing_notification', 10, 1); 


function get_processing_notification_content($order, $heading = false, $mailer) { 

    $template = 'emails/customer-processing-order.php'; 

    return wc_get_template_html($template, array(
     'order'   => $order, 
     'email_heading' => $heading, 
     'sent_to_admin' => true, 
     'plain_text' => false, 
     'email'   => $mailer 
    )); 
} 

回答

相關問題