在以前版本的Woocommerce中,当订单从挂起状态更改为已取消状态时,会自动发送电子邮件通知(在我的情况下,这会在管理员的清单部分中设置的分配时间之后发生).
在WooCommerce 3.0.8中,他们删除了这种自动化并标记为修复:
https://github.com/woocommerce/woocommerce/blob/master/CHANGELOG.txt
拉请求在这里:
https://github.com/woocommerce/woocommerce/pull/15170/files
我正在寻求恢复此功能,但显然将此行复制/粘贴回Woocommerce核心文件并不是一个好主意,因为它会在平台更新时被覆盖.
我知道最好的方法是创建一个函数并通过functions.php挂钩取消的订单操作,但看了之后我有点迷失了如何做到这一点.这是被替换的线:
add_action( 'woocommerce_order_status_pending_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
如何恢复这个旧的自动化功能?
解决方法:
好新:使用带有自定义函数钩子的woocommerce_order_status_pending_to_cancelled
动作钩子,最终解决您的问题:
add_action('woocommerce_order_status_pending_to_cancelled', 'cancelled_send_an_email_notification', 10, 2 );
function cancelled_send_an_email_notification( $order_id, $order ){
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Sending the email
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
}
代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中.
经过测试,完美适用于WooCommerce 3(和3.1)
原文地址:https://codeday.me/bug/20191007/1865271.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。