Reputation: 1945
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.
}
Upvotes: 1
Views: 1679
Reputation: 64
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
Upvotes: 1