1

I have found a partial and workable answer to my question in this related answer:
send-an-email-notification-when-order-status-changhe-fron-pendig-to-cancelled

I'm thinking to use the solution provided but would like to see if I could change the email notification to clearly say "pending payment order now canceled" so it differs from the regular canceled orders.

How would I do this?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Lyse
  • 53
  • 1
  • 8

1 Answers1

0

You could try this that will customize the heading and the subject of this email:

add_action('woocommerce_order_status_pending_to_cancelled', 'cancelled_send_an_email_notification', 10, 2 );
function cancelled_send_an_email_notification( $order_id, $order ){
    // Getting all WC_emails objects
    $email_notifications = WC()->mailer()->get_emails();

    // Cancelled Order email notification
    $email_obj = $email_notifications['WC_Email_Cancelled_Order'];

    // Customizing heading and subject
    $email_obj->settings['heading'] = __( "Pending payment order now Cancelled", "woocommerce" );
    $email_obj->settings['subject'] = __( "[{site_title}] Pending payment order ({order_number}), now Cancelled", "woocommerce" );

    // Sending the email
    $email_obj->trigger( $order_id );
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399