簡體   English   中英

在WooCommerce中自定義客戶處理電子郵件通知

[英]Customizing customer processing emails notification in WooCommerce

我是WordPress的新手,並通過WooCommerce創建了一家電子商務商店。

客戶下訂單后,我會收到一封電子郵件,然后客戶會收到一封電子郵件-一個讓我說他們訂購的商品,另一個給他們作為感謝信。

在此感謝電子郵件中,在我的functions.php文件中,我學會了更改標題的主題以包括其名稱,例如:

//add the first name of the person to the person getting the reciept in the subject of the email. 
add_filter('woocommerce_email_subject_customer_processing_order','UEBC_change_processing_email_subject', 10, 2);

function UEBC_change_processing_email_subject( $subject, $order ) {
global $woocommerce;
$subject = 'Thanks for your ' . get_bloginfo( 'name', 'display' ) . ' Order, '.$order->billing_first_name .'!';
return $subject;
}

上面的代碼段可以正常工作,並且僅顯示給客戶,而不顯示給我。 例如:“感謝您訂購ABCD衣服訂購John!”。 在電子郵件的正文中,我試圖將其作為一條小小的感謝消息,但是,當我發送此消息時,我使用的是鈎子:

add_action( 'woocommerce_email_before_order_table', 'custom_add_content', 20,1 );

我知道,由於即時通訊使用woocommerce_email_before_order_table掛鈎,因此自定義功能將在電子郵件正文中發送給客戶和我自己。

我想知道,Woocommerce是否提供了一個掛鈎,以便自定義功能僅在電子郵件正文中發送給客戶?

例如: woocommerce_email_header_customer_processing_orderwoocommerce_email_header_customer_processing_order詞?

謝謝

要使用woocommerce_email_before_order_table掛鈎添加一些自定義內容,並僅定位客戶“處理訂單”電子郵件通知 ,您應該嘗試以下操作:

add_action( 'woocommerce_email_before_order_table', 'custom_content_to_processing_customer_email', 10, 4 );
function custom_content_to_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

    if( 'customer_processing_order' == $email->id ){

        // Set here as you want your custom content (for customers and email notification related to processing orders only)
        echo '<p class="some-class">Here goes your custom content… </p>';

    }

}

代碼進入您的活動子主題(或主題)的function.php文件中。 或在任何插件php文件中。

此代碼已經過測試並可以正常工作

暫無
暫無

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

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