Search code examples
phpwordpresswoocommerceordersemail-notifications

How to add custom email notification in Woocommerce?


As title mentioned, is there any possible way to add email notification just like email to customer on cancelled order. I would like to email to notice on cancelled order due to time limit of pending payment.

Any possible way??

enter image description here


Solution

  • Here is a custom hooked function in woocommerce_email_recipient_cancelled_order filter hook:

    add_filter( 'woocommerce_email_recipient_cancelled_order', 'adding_customer_email_recipient_to_cancelled', 10, 2 );
    function adding_customer_email_recipient_to_cancelled( $recipient, $order ){
        if( is_admin() ) return $recipient;
    
        $billing_email = $order->get_billing_email();
        $recipient .= ', ' . $billing_email; 
    }
    

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

    This code is tested and works on WooCommerce 3.0+