Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('woocommerce_order_status_changed', 'bdev_send_cancelled_order_email_notification_to_customer', 10, 4 );
- function bdev_send_cancelled_order_email_notification_to_customer( $order_id, $old_status, $new_status, $order ){
- if ( $new_status == 'cancelled' || $new_status == 'failed' ){
- $wc_emails = WC()->mailer()->get_emails();
- $customer_email = $order->get_billing_email();
- }
- if ( $new_status == 'cancelled' ) {
- $wc_emails['WC_Email_Cancelled_Order']->recipient = $customer_email;
- $wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id );
- }
- elseif ( $new_status == 'failed' ) {
- $wc_emails['WC_Email_failed_Order']->recipient = $customer_email;
- $wc_emails['WC_Email_failed_Order']->trigger( $order_id );
- }
- }
Add Comment
Please, Sign In to add comment