禁用 WooCommerce 手动/编辑订单的电子邮件通知 [英] Disable email notification for WooCommerce manual/edit orders

查看:23
本文介绍了禁用 WooCommerce 手动/编辑订单的电子邮件通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要 WooCommerce 专业知识

WooCommerce expertise needed

我需要为手动创建的订单禁用电子邮件通知,我必须使用处理状态,由于处理订单状态的自定义挂钩,我无法创建自定义状态.

I need to disable email notifications for orders that I create manually, I have to use the processing status, I can't create a custom status because of a custom hook for the processing order status.

理想情况下,可以勾选手动订单页面中的复选框,勾选后,它将禁止在每个状态下向客户发送电子邮件.(处理 - 完成).

Ideally a checkbox in the manual order page that could be ticked and when it is ticked it will disable email from sending to the customer at every status. (processing - completed).

原因是由于数据库原因,ebay 订单必须输入到后端订单中,我们不希望将已通过 ebay 发送的电子邮件重新发送给客户.

Reason is that ebay orders have to be entered into the backend orders for database reasons and we dont want emails resent to the customer that have already been sent via ebay.

我猜这个钩子需要被调用:

I am guessing that this hook will need to be called:

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' ) );

推荐答案

如果您只想从管理员中删除它们并在客户在前端购买东西时继续发送新订单电子邮件,请将操作删除包装在一些逻辑中检查这种情况.我已经包含了这个 WooCom 示例中的所有相关电子邮件(https://docs.woocommerce.com/document/unhookremove-woocommerce-emails/),删除那些不是通过在管理员中创建/编辑订单生成的或者已经可以选择发送或不发送的那些(注释).

If you only want to remove them from the admin and continue to have new order emails sent when customers purchase things on the frontend, wrap the action removals in some logic to check for that case. I have included all of the relevant emails from this WooCom example (https://docs.woocommerce.com/document/unhookremove-woocommerce-emails/), removing the ones that either are not generated by creating/editing orders in the admin or already have an option to send or not send (notes).

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' ) );

    }
}

这篇关于禁用 WooCommerce 手动/编辑订单的电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆