/*------------------------------------*\
CAT:Woocommerce hacks
\*------------------------------------*/
//Send email notification about cancelled order
//init new email action
function add_cancel_order_email_action($attrs) {
$attrs[] = 'woocommerce_order_status_pending_to_cancelled';
return $attrs;
}
add_filter('woocommerce_email_actions', 'add_cancel_order_email_action');
//trigger sending
function trigger_pending_to_cancelled_mail_send($order_id){
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) ) {
foreach ( $mails as $mail ) {
if ( $mail->id == 'cancelled_order' ) {
$mail->trigger( $order_id );
}
}
}
}
add_action( 'woocommerce_order_status_pending_to_cancelled_notification', 'trigger_pending_to_cancelled_mail_send', 10, 2 );