Support » Plugin: WooCommerce » Send copy emails – Failed and Paused

  • Resolved amc11

    (@amc11)


    Hi,

    I have struggled for a while trying to create to additional email that should
    be sent to Admin and Customer. Additional the Admin should receive the email going from Pending to Paused order, and the Customer one for goin from Paused to Failed order. I would really like to send the same emails that are configured in Settings->Email.

    Would really appreciate some help on this.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Rashed Ripon (a11n)

    (@rur165)

    Hello @amc11 ,

    I understand your request.

    Creating a new email for a specific action will require custom development. Here is a developer guideline that you can follow on How to Add a Custom WooCommerce Email.

    This is actually a fairly complex development topic.

    I can recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. Weโ€™re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    If you need a paid solution, you can consider taking help from one of our partner’s website.

    Thank you ๐Ÿ™‚

    Thread Starter amc11

    (@amc11)

    Hi,

    Thank you for the reply.
    Of course I could hire someone ๐Ÿ™‚

    The problem im facing could actually be a bug.

    I do this simple function within woocommerce_order_status_changed.

    
    function send_custom_email_notifications( $order_id, $old_status, $new_status, $order ){
    $wc_emails = WC()->mailer()->get_emails();
    $wc_emails['WC_Email_Customer_On_Hold_Order']->recipient = 'xxxxxx@domain';
    $wc_emails['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
    }
    add_action('woocommerce_order_status_changed', 'send_custom_email_notifications', 10, 4 );
    

    It sends two emails to the mailadress in Woo settings. But not to
    the above email adress (ofcourse a correct one)..

    Its a bit strange.

    What I’ve noticed, this doesn’t happen for status changed to Failed.
    Were it sends two mails. One to the customer (the order email) and one to admin (default).

    • This reply was modified 9 months ago by amc11.
    • This reply was modified 9 months ago by amc11.
    Thread Starter amc11

    (@amc11)

    So ive tested it some time now, and it actually sends an New Order mail to the Admin when the status changes to Paused (On-Hold) within the order in admin. Now I understand why in the production environment for our customer, this happens, it should not work that way. It must be a bug!

    Please look into this.

    Thread Starter amc11

    (@amc11)

    So it sends one new order mail to admin and two mails to
    customer mail for On-Hold status. It doesn’t care about the
    below recipient email. It just triggers the customer mail another
    time.

    $wc_emails[‘WC_Email_Customer_On_Hold_Order’]->recipient = ‘xxxxx@domain’;

    // Sending the email from this instance
    $wc_emails[‘WC_Email_Customer_On_Hold_Order’]->trigger( $order_id );

    • This reply was modified 9 months ago by amc11.
    Thread Starter amc11

    (@amc11)

    I tried some more, and currently it sends a New Order mail
    when using customer_on_hold_order and failed.

    Im using woocommerce_email_headers instead now.
    myemail is ofcourse a real mail but not in below.

    
    
    function add_bcc_to_certain_emails( $headers, $object, $order ) {		
    	if ( $object == 'customer_on_hold_order' ) {
    		$headers = array( $headers,'Bcc: myemail' ."\r\n");
    	}
    	if ( $object == 'failed_order' ) {
    		$customer_email = $order->get_billing_email();	
    		$headers = array( $headers,'Bcc: ' . $customer_email ."\r\n");
    	}
    	return $headers;
    }
    add_filter( 'woocommerce_email_headers', 'add_bcc_to_certain_emails', 10, 3 );
    
    
    Plugin Support Rashed Ripon (a11n)

    (@rur165)

    Hello @amc11 ,

    It’s good to see that you are sharing your progress and now you have got it working. I am sure someone else will also find it useful.

    Is there anything else that I can help with on this topic?

    Thank you ๐Ÿ™‚

    Plugin Support Rashed Ripon (a11n)

    (@rur165)

    Hi there,

    Weโ€™ve not heard back from you in a while, so Iโ€™m marking this thread as resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Thank you ๐Ÿ™‚

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Send copy emails – Failed and Paused’ is closed to new replies.