繁体   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