Woocommerce - update order status without sending customer email

I am currently using

$order = new WC_Order($order_id);
$order->update_status('completed', 'Order has been delivered.'); 

to update the order status, but it sends the customer an email. I have hundreds of old customers and I don’t want to be emailed when I update my status. Is there an alternative way to change order status without sending emails?

+4
source share
1 answer

WooCommerce by default provides the ability to disable full email notification of orders. Here you can find the settings.

Set up WooCommerce to turn off email notifications

enter image description here

, , , WooCommerce Autocomplete Order functions.php, "wp-content/themes/your-theme-name/:":

/**  * WooCommerce.  */

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) { 
    if ( ! $order_id ) {
        return;
    }

    $order = wc_get_order( $order_id );
    $order->update_status( 'completed' );
}

,

+5

All Articles