Stop Duplicate Suborder Emails for Processing and On Hold

In 2019, WCMp transitioned to a split order system. Unfortunately there are many long-lasting teething problems with this. One of them is that new order emails are sent to the customer for not only the parent order, but also each split suborder. So if your customer orders from 5 vendors at once, he/she would receive 6 email confirmations. That’s silly. So this code stops the emails generated by a new processing or on hold order.

As always, this is either added to your Child Theme’s functions.php file, or consider using the My Custom Functions Pro plugin to manage and organize all your snippets.

add_filter( 'woocommerce_email_recipient_customer_on_hold_order', 'customer_email_recipient_change',10,2);
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'customer_email_recipient_change',10,2);

function customer_email_recipient_change( $recipient_name , $object_name ){
   $parent_order_id = wp_get_post_parent_id( $object_name->get_id() );
   if( $parent_order_id == 0 ) {
       return $recipient_name;
   } else {
       return;
   }
}

Not tested in awhile…

Is this no longer relevant or not working? Please let us know in the comments!

Comments on this post

Your email address will not be published. Required fields are marked *