Reputation: 1328
I am trying to stop woo-commerce from sending mail when order status is changed. These orders are of amazon and my plugin syncs it from amazon to woo-commerce. On doing so, mail from both amazon and woo-commerce went, which irritated the clients. So I want to stop email functionality to be stopped when status is changed from my plugin. the code to change status is
$WooOrder = wc_get_order($value->post_id);
$WooOrder->set_address($OrderData['billing'], 'billing')
$WooOrder->update_status($wooOrderStatus) // $wooOrderStatus is set above
Are there any flags that can be set to avoid sending mails?
Any kinds of helps are highly appreciated.
Upvotes: 1
Views: 1778
Reputation: 253968
Instead of using WC_Order
update_status()
method, simply use wp_update_post()
as follow:
$WooOrder = wc_get_order($value->post_id);
$WooOrder->set_address($OrderData['billing'], 'billing');
$WooOrder->save();
// Change order status
wp_update_post(['ID' => $value->post_id, 'post_status' => 'wc-'.$wooOrderStatus]);
This should change the Order status without sending an email notification.
Note: Post status for WooCommerce Orders always start with wc-
Upvotes: 7