Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

woocommerce - update order status without sending customer email

Tags:

woocommerce

I currently use

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

to update order status but this sends out an email to the customer. I have hundreds of old customers and i don't want emails to be sent for to them when i update the status. Is there an alternative way to change the status of an order without sending emails?

like image 724
user892134 Avatar asked Jun 24 '15 09:06

user892134


1 Answers

WooCommerce by default provides an option to disable complete orders email notification. Here is where you can find the setting.

Configuring WooCommerce to disable Email notification

enter image description here

If this is not what you want and if you want to auto complete orders after it placed you can use the WooCommerce Autocomplete Order or you can just code it your self by adding this code at the end of your functions.php file, which is located in “wp-content/themes/your-theme-name/:” :

/** * Auto Complete all WooCommerce orders. */

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

Let me know if this solution fits your requirements

like image 119
Domain Avatar answered Sep 17 '22 22:09

Domain