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?



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 );
  • Thank you. Any way to ensure someone doesn't abuse it, i.e. if I throw that into a specific place on the thankyou page, is there anyway to not send an email every time a person refreshes the page? – user3210369 Apr 20 '15 at 3:51
  • WooCommerce take care of this thing as plugin only send email on hooks. But you are sending it on thank you page, then you need to take care of this, you can add some meta value to user meta or store some cookies in his/her browser. and please mark this answer as accepted as it does your current job. – Sumit Apr 20 '15 at 7:16

Rather than looping or reusing the same object as suggested by @Sumit. You can initiate a new object and then call the trigger.

$email_oc = new WC_Email_Customer_Completed_Order();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.