亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

WooCommerce 向管理員發送電子郵件通知以獲取特定訂單狀態

WooCommerce 向管理員發送電子郵件通知以獲取特定訂單狀態

PHP
千萬里不及你 2023-05-26 14:27:13
以下是我在訂單狀態變為“處理中”時向管理員發送通知電子郵件的代碼:add_action( 'woocommerce_checkout_order_processed', 'process_new_order_notification', 20, 1 );function process_new_order_notification( $order_id ) {    // Get an instance of the WC_Order object    $order = wc_get_order( $order_id );    //Order status processing    if( ! $order->has_status( 'processing' ) ) return;    // Send "New Email" notification (to admin)    WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id );}但它不起作用,因為當訂單狀態變為處理中時,管理員不會收到任何電子郵件。我認為我的代碼有問題。有什么幫助嗎?
查看完整描述

1 回答

?
阿晨1998

TA貢獻2037條經驗 獲得超6個贊

您可以使用woocommerce_order_status_$STATUS_TRANSITION[to]復合鉤子將“處理”狀態轉換$STATUS_TRANSITION[to]為processing,這將簡化和壓縮代碼,例如:


add_action( 'woocommerce_order_status_processing', 'process_new_order_notification', 20, 2 );

function process_new_order_notification( $order_id, $order ) {

? ? // Send "New Email" notification (to admin)

? ? WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id );

}

代碼進入您的活動子主題(或活動主題)的 function.php 文件。它應該更好地工作。

查看完整回答
反對 回復 2023-05-26
  • 1 回答
  • 0 關注
  • 187 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號