2017-08-17 60 views
2

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

如何恢复这个旧的自动功能?

回答

4

好新:使用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+)

+0

感谢这个,完美! –

0

所以我在这里将这些信息以供将来参考,我不能因为少声誉发表评论。

自3.0.9版本以来,此问题已被固定由Woocommerce通知发送给管理员。 Link

* Fix - Updated `woocommerce_email_actions` to send email when order status changes from processing to cancelled. 

您不再需要此代码。

相关问题