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?
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With