订单提交后如何发送额外的电子邮件(Woocommerce)?

时间:2017-10-10 04:55:31

标签: php wordpress

我正在尝试在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
    ) );
}

1 个答案:

答案 0 :(得分:1)

我认为您正在寻找woocommerce_email_order_details

https://docs.woocommerce.com/wc-apidocs/hook-docs.html