从 Woocommerce 的电子邮件通知中删除列数量

Rim*_*Kio 2 php wordpress templates email-notifications woocommerce

在 Woocommerce 中,我想从电子邮件通知中删除列 Quantity,如下面的屏幕截图所示:

任何帮助表示赞赏。

Loi*_*tec 5

这可以通过 Theme 覆盖以下 WooCommerce 模板来完成。

相关的模板email/email-order-items.phpemails/email-order-details.php

将此模板复制到yourtheme/woocommerce/emails/email-order-items.phpyourtheme/woocommerce/emails/email-order-details.php打开后对其进行编辑:

1)对于模板email/email-order-items.php

  • 第 78 行更改<td colspan="3"<td colspan="2"

  • 从第 66 行到 68 行删除以下代码块:

    <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
    <?php echo wp_kses_post( apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ) ); ?>
    
    Run Code Online (Sandbox Code Playgroud)

2)对于模板email/email-order-details.php

  • 第 70 行更改<th class="td" scope="row" colspan="2"<th class="td" scope="row"

  • 第 79 行更改<th class="td" scope="row" colspan="2"<th class="td" scope="row"

  • 删除第 45 行的代码块:

    <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
    
    Run Code Online (Sandbox Code Playgroud)

保存两个模板,你就完成了……你会得到类似的东西:

在此处输入图片说明