簡體   English   中英

WooCommerce 產品供應商:向供應商發送收到新訂單的通知

[英]WooCommerce Product Vendors: Send notification to vendor for new order received

我正在使用WooCommerce 產品供應商插件進行供應商管理。

目前,當收到新訂單時,通知會發送給客戶和管理員。 一旦管理員將訂單狀態更改為“處理中”或“已完成” ,電子郵件就會發送給供應商。

但是我需要在收到訂單時發送該通知電子郵件。

這可以通過在functions.php創建過濾器或通過在收到訂單時觸發產品狀態更改通知來實現嗎?

更新:添加了“新預訂”電子郵件通知 ID...

有很多方法可以實現這一目標。 這里我有兩個:

1)。 第一個,基於電子郵件 ID“新訂單”。 它經過測試並有效:

add_action ('woocommerce_email_customer_details', 'new_order_email_to_vendor', 20, 4 );
function new_order_email_to_vendor( $order, $sent_to_admin, $plain_text, $email ){
    if( in_array( $email->id, ['new_order', 'new_booking'] ) ){ 
        $mailer['WC_Product_Vendors_Order_Email_To_Vendor']->trigger( $order );
    }
}

代碼位於活動子主題(或主題)的 function.php 文件或任何插件文件中。


2)。 這是未經測試的,因為它基於訂單狀態更改條件。 您可以在 if 語句中設置“from”訂單狀態或某些“to”訂單狀態或兩者...

在這里,我僅使用“來自”“待處理”訂單狀態,因為在 Woocommerce 的付款過程中,所有訂單始終設置為待處理狀態:

add_action( 'woocommerce_order_status_changed', 'new_order_email_to_vendor', 10, 4 );
function new_order_email_to_vendor( $order_id, $old_status, $new_status, $order ){

    if ( in_array( $new_status, array( 'processing','completed') ) { // <== Updated
        $emails = WC()->mailer()->get_emails();
        $emails['WC_Product_Vendors_Order_Email_To_Vendor']->trigger( $order );
    }
}

代碼位於活動子主題(或主題)的 function.php 文件或任何插件文件中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM