2017-08-17 70 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. 

您不再需要此代碼。

相關問題