【问题标题】:Remove product purchase notes in certain WooCommerce email notifications删除某些 WooCommerce 电子邮件通知中的产品购买说明
【发布时间】:2021-12-27 11:42:35
【问题描述】:

我尝试从订单完成邮件中删除购买说明。目前,购买说明在订单确认邮件和订单完成邮件中。但我们不希望订单完成邮件中包含该信息。

所以我在这里找到了这个输入: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;
}

【问题讨论】:

    标签: php wordpress woocommerce product email-notifications


    【解决方案1】:

    您可以使用电子邮件 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 );
    

    注意:How to target other WooCommerce order emails

    在这个答案中使用:Changing in WooCommerce email notification Order Item table "Product" label

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2020-10-02
      • 1970-01-01
      • 1970-01-01
      • 2021-01-04
      相关资源
      最近更新 更多