I have searched the web and checked the WooCommerce docs for a solution to disable the "confirmation email" that is sent to the customer when they place an order in WooCoomerce.
I also want to disable the "new order" mail that goes to the admin.
But only if the order has a custom status "mystatus", which some orders are getting based on what the customers are ordering.
Tried adding it like this, but it did not work:
remove_action( 'woocommerce_order_status_mystatus_notification', array($email_class->emails['WC_Email_New_Order'], 'trigger' ) );?>
Any advice?
This is how I change the order status for specific orders:
add_action( 'woocommerce_thankyou','woocommerce_thankyou_change_order_status', 10, 1 );
function woocommerce_thankyou_change_order_status( $order_id ){
if( ! $order_id ) return;
$order = wc_get_order( $order_id );
$user_id = $order->get_user_id();
if( ($order->get_status() == 'processing' || $order->get_status() == 'pending' || $order->get_status() == 'on-hold' ) && dokan_is_user_seller( $user_id ) && is_user_logged_in()) {
$order->update_status( 'mystatus' );
}
}