簡體   English   中英

刪除某些 WooCommerce 電子郵件通知中的產品購買說明

[英]Remove product purchase notes in certain WooCommerce email notifications

我嘗試從訂單完成的郵件中刪除購買說明。 目前,購買說明在訂單確認郵件和訂單完成郵件中。 但我們不希望訂單完成郵件中的信息。

因此,我在這里找到了這個輸入: 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;
}

您可以使用電子郵件 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 電子郵件通知中更改訂單項目表“產品”標簽

暫無
暫無

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

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