我嘗試從訂單完成的郵件中洗掉購買說明。目前,購買說明在訂單確認郵件和訂單完成郵件中。但我們不希望訂單完成郵件中的資訊。
因此,我在這里找到了這個輸入:https : //wordpress.stackexchange.com/questions/340045/how-do-i-hide-the-purchase-note-in-the-woocommerce-order-completed-email
我還發現在下面剪斷了。但是,它會隨處洗掉它,而不僅僅是按照完整郵件的順序。有什么建議嗎?
add_filter('woocommerce_email_order_items_args','remove_order_note',12);
function remove_order_note($args){
$args['show_purchase_note']= false;
return $args;
}
uj5u.com熱心網友回復:
您可以使用電子郵件 ID 來定位 WooCommerce 中的特定電子郵件通知。但是,因為這在您使用的鉤子中是未知的,我們將通過另一個鉤子使電子郵件 ID 全域可用
所以你得到:
// Setting the email_is as a global variable
function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {
$GLOBALS['email_id_str'] = $email->id;
}
add_action( 'woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );
function filter_woocommerce_email_order_items_args( $args ) {
// Getting the email ID global variable
$refNameGlobalsVar = $GLOBALS;
$email_id = isset( $refNameGlobalsVar['email_id_str'] ) ? $refNameGlobalsVar['email_id_str'] : '';
// Targeting specific email. Multiple statuses can be added, separated by a comma
if ( in_array( $email_id, array( 'customer_completed_order', 'customer_invoice' ) ) ) {
// False
$args['show_purchase_note'] = false;
}
return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'filter_woocommerce_email_order_items_args', 10, 1 );
注意:如何定位其他 WooCommerce 訂單電子郵件
在此答案中使用:在 WooCommerce 電子郵件通知中更改訂單專案表“產品”標簽
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/358716.html
標籤:php WordPress的 求购 产品 电子邮件通知
上一篇:html標題背景顏色?
