[英]Add a custom text to specific email notification for local pickup Woocommerce orders
[英]woocommerce add text to specific email
我之前曾問過這個問題,但很遺憾,我意識到給出的答案沒有用,所以我再次問:
我正在嘗試向WooCommerce
的客戶訂單處理電子郵件中添加一些文本,並且僅應將其添加到此特定電子郵件中,並且僅當選擇的付款方式為Paypal
WooCommerce
應添加。 到目前為止,我只添加了文本,僅當選擇了Paypal作為付款方式時,文本才顯示在現在發給客戶的每封電子郵件中,例如在訂單已完成的電子郵件或客戶備忘電子郵件中也顯示。 我有以下內容:
add_action('woocommerce_email_before_order_table','add_order_email_instructions', 0, 2);
function add_order_email_instructions( $order, $sent_to_admin ) {
if ( 'paypal' == $order->payment_method && ! $sent_to_admin ) {
echo 'my text:';
}
}
我嘗試了其他條件,例如! $order->has_status( 'processing' )
,但是沒有任何作用。 有什么幫助嗎?
我只想向狀態為“保留”並發送給管理員(而非客戶)的電子郵件添加注釋。 這對我來說很好:
/* Add manual processing note to new orders to admin */
add_action( 'woocommerce_email_order_details','add_order_email_instructions', 10, 4 );
function add_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
if ( $order->status == 'on-hold' && $sent_to_admin ) {
echo '<p><strong>Note: Manual processing for this order is required.</strong></p>';
}
}
操作...我不知道為什么我以為您的電子郵件根本沒有被觸發。
順便說一句,如果您只想將該文本添加到特定的電子郵件模板,則有兩種方法:
1)更難的一種:禁用“客戶訂單處理”並創建自己的電子郵件模板。 您可以從本教程開始: https : //www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
2)一個簡單的建議 :覆蓋'customer-order-processing.php'並在該模板中添加一些代碼。
步驟如下:
打開“ customer-processing-order.php”並在所需的位置添加所需的代碼:
if('paypal'== $ order-> payment_method){回聲'我的文本:'; }
代碼未經測試,但可以正常工作!
祝好運 ;)
我相信我的補丁應該可以在WooCommerce 2.5中獲得 。 啟用該woocommerce_email_before_order_table
后, $email
對象將在woocommerce_email_before_order_table
鈎子(以及電子郵件中的其他鈎子)上可用,您將能夠測試特定電子郵件的$email->id
。 在functions.php
(或最好在插件中)中執行以下操作即可:
add_action( 'woocommerce_email_before_order_table','add_order_email_instructions', 10, 4 );
function add_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
if ( 'customer_processing_order' == $this->id && 'paypal' == $order->payment_method && ! $sent_to_admin ) {
echo 'my text:';
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.