[英]Change WooCommerce order status change without sending email notification
I am trying to stop woo-commerce from sending mail when order status is changed. 订单状态更改时,我试图阻止woo-commerce发送邮件。 These orders are of amazon and my plugin syncs it from amazon to woo-commerce. 这些订单来自亚马逊,我的插件将其从亚马逊同步到woo-commerce。 On doing so, mail from both amazon and woo-commerce went, which irritated the clients. 这样一来,来自亚马逊和woo-commerce的邮件就发了起来,这激怒了客户。 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. 任何帮助都将受到高度赞赏。
Instead of using WC_Order
update_status()
method, simply use wp_update_post()
as follow: 代替使用WC_Order
update_status()
方法,只需使用wp_update_post()
,如下所示:
$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-
注意: WooCommerce订单的过帐状态始终以wc-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.