I want to be able to trigger the WooCommerce order complete email at a different stage in the WooCommerce checkout process. So I’ve disabled WooCommerce order complete email from the backend and am now looking for a line of code that will trigger the email at the point that I want. I’ve done a bit of research and I’ve found how to remove the order complete email but not how to trigger it manually. Any tips?

Thanks!

3

You can try this

$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) ) {
    foreach ( $mails as $mail ) {
        if ( $mail->id == 'customer_completed_order' ) {
           $mail->trigger( $order->id );
        }
     }
}

Leave a Reply

Your email address will not be published. Required fields are marked *