Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Disable WooCommerce order email notification for orders with custom status

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' );
  }
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

No real need to make any changes to WooCommerce settings.

No email-notifications will be sent for a custom order status, unless you effectively provide this.

However, the default email-notifications are sent, because the woocommerce_thankyou hook is executed after the email-notifications have been sent.

So use the woocommerce_checkout_order_created hook (that is executed, before the e-mail notifications are sent) opposite woocommerce_thankyou to change the order status, and no emails will be sent anyway.

function action_woocommerce_checkout_order_created( $order ) {
    // Get user ID
    $user_id = $order->get_user_id();
    
    // Compare
    if ( ( $order->get_status() == 'processing'  || $order->get_status() == 'pending' || $order->get_status() == 'on-hold' ) && dokan_is_user_seller( $user_id ) && is_user_logged_in() ) {
        // Update status
        $order->update_status( 'mystatus' );
    }
}
add_action( 'woocommerce_checkout_order_created', 'action_woocommerce_checkout_order_created', 10, 1 );

Note: If you want to disable emails in any other case, you can use the woocommerce_email_recipient_{$email_id} filter composite hook and with the right email ID set, you have the option to disable email notifications.

For instance:

// Admin - new order email notification
// Customer - on hold
// Customer - processing
// Customer - pending
function filter_woocommerce_email_recipient( $recipient, $order, $email ) { 
    if ( ! $order || ! is_a( $order, 'WC_Order' ) ) return $recipient;
    
    // Has order status
    if ( $order->has_status( 'your-order-status' ) ) {
        $recipient = '';
    }

    return $recipient;
}
add_filter( 'woocommerce_email_recipient_new_order', 'filter_woocommerce_email_recipient', 10, 3 );
add_filter( 'woocommerce_email_recipient_customer_on_hold_order', 'filter_woocommerce_email_recipient', 10, 3 );
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'filter_woocommerce_email_recipient', 10, 3 );
add_filter( 'woocommerce_email_recipient_customer_pending_order', 'filter_woocommerce_email_recipient', 10, 3 );
over 4 years ago · Santiago Trujillo Report

0

Disable the mail under WooCommerce >> Settings >> Emails you want to only sent in case your order has a custom status.

Now just sent it in case your order has the correct status:

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' );

        $email_oc = new WC_Email_Customer_Completed_Order();
        $email_oc->trigger($order_id);
    }
}

You can just sent every WooCommerce mail from PHP you want.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!