0
votes

I need to disable email notifications for particular order ID. For example in woocommerce order id 2378 then i want to disable all email notification for customer only for this order ID. Because i continue to have issues where an order changes statuses by itself. This has been an ongoing issue for us and unfortunately, i haven’t been able to find the cause.However, there has been one particular order that keeps changing statuses ever since it was first placed way back in September.

I found some code for disabling email notification below is that code.But i don't know how to use that function with particular order ID.

add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );

function unhook_those_pesky_emails( $email_class ) {

remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); // cancels automatic email of order complete status update.
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); // cancels automatic email of new order placed (when defined to procession status)
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) ); // cancels automatic email of status update to processing.
}
1
put your code in functions.php file and check it. - Priyanka Modi
When i put this code then all automatic email notifications was disabling. - developerme
you have used wordpress theme from folder structure. right?? there is theme folder which you have activated in the project. there is one functions.php file in theme folder and there is put the code. Hope! you understand ... - Priyanka Modi
@PriyankaModi I know that but this code is not working for me that is why i ask here this question when i put this code the all email notification is not working. I want to disable email notification for particular order do you get what i meant ? - developerme
Unfortunately, this is just not possible… - LoicTheAztec

1 Answers

0
votes

Pretty late to the party, but it might help somebody.

How about this idea?

add_filter( 'woocommerce_email_recipient_customer_on_hold_order', 'customer_on_hold_order_for_specified_order', 10, 2 );

function customer_on_hold_order_for_specified_order( $recipient, $order ) {
    if( is_a($order, 'WC_Order') && $order->get_id() === 2378 ) {
        $recipient = '';
    }
    return $recipient;
}

And doing this one for every activated email?

Give credit where credit is due: thank you @LoicTheAztec