需要WooCommerce专业知识
我需要为我手动创建的订单禁用电子邮件通知,我必须使用处理状态,因为处理订单状态的自定义挂钩,我无法创建自定义状态。
理想情况下,手动订单页面中的复选框可以勾选,当它被勾选时,它将禁止电子邮件在每种状态下发送给客户。 (处理 - 完成)。
原因是因为数据库原因必须将ebay订单输入后端订单,我们不希望通过ebay发送给客户的电子邮件重新发送。
我猜这个钩子需要被调用:
remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
而且:
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
答案 0 :(得分:3)
我可以看到你在这里没有回复,不确定你是否设法解决了这个问题,但对于寻找此信息的其他人也是如此,请参考功能:
https://docs.woocommerce.com/document/unhookremove-woocommerce-emails/
在functions.php或自定义插件中:
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); // cancels automatic email of order complete status update.
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) ); // cancels automatic email of new order placed (when defined to procession status)
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) ); // cancels automatic email of status update to processing.
}
答案 1 :(得分:1)
如果您只想从管理员中删除它们并继续在客户购买前端时发送新的订单电子邮件,请将操作删除包装在某个逻辑中以检查该情况。我已经包含了来自这个WooCom示例(https://docs.woocommerce.com/document/unhookremove-woocommerce-emails/)的所有相关电子邮件,删除了那些不是通过在管理员中创建/编辑订单生成的或者已经有发送或不发送选项(注释)的电子邮件。
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
if ( is_admin() && ! wp_doing_ajax() ) {
// New order emails
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_pending_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_processing_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_completed_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $email_class->emails['WC_Email_New_Order'], 'trigger' ) );
// Processing order emails
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
remove_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
// Completed order emails
remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) );
}
}