我已在网上搜索并查阅了WooCommerce文档,以解决禁用顾客在WooCoomerce下单时发送的“确认邮件”的问题。
我还想禁用发给管理员的“新订单”邮件。
但仅当订单具有自定义状态“mystatus”时才这么做,这取决于客户订购的商品。
我试过像这样添加,但没有成功:
remove_action( 'woocommerce_order_status_mystatus_notification', array($email_class->emails['WC_Email_New_Order'], 'trigger' ) );?>
有什么建议吗?
以下是如何更改特定订单状态的方法:
add_action( 'woocommerce_thankyou','woocommerce_thankyou_change_order_status', 10, 1 );
function woocommerce_thankyou_change_order_status( $order_id ){
if( ! $order_id ) return;
$order = wc_get_order( $order_id );
$user_id = $order->get_user_id();
if( ($order->get_status() == 'processing' || $order->get_status() == 'pending' || $order->get_status() == 'on-hold' ) && dokan_is_user_seller( $user_id ) && is_user_logged_in()) {
$order->update_status( 'mystatus' );
}
}