dongruidian3064 2017-09-11 07:35
浏览 103
已采纳

Woocommerce电子邮件通知中的样式订单详细信息表

I am using WordPress 4.8.1 and using bridge theme.
I am facing some problem regarding removing price from new order template email.
I want to remove price column ,however I removed total and subtotal , but not getting anything to remove price column with products as going through files.

I have found this is coming from this code:

 <?php 
    echo wc_get_email_order_items( $order, array(
                'show_sku'      => $sent_to_admin,
                'show_image'    => false,
                'image_size'    => array( 32, 32 ),
                'plain_text'    => $plain_text,
                'sent_to_admin' => $sent_to_admin,
            ) ); ?>

In email-order-details.php template which I have copied to my child theme from woocommerce template folder.

But , how to customise this hook 'wc_get_email_order_items' or any other way to remove price?

This is what I have now:

enter image description here

Any help will be appreciated as I have spent so much hours finding solution for same.

  • 写回答

2条回答 默认 最新

  • drhib62644 2017-09-11 09:47
    关注

    This can be done Overriding the following WooCommerce Templates via a Theme:

    1.Template email/email-order-details.php

    • Where you will remove the block at line 38:
    <th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Price', 'woocommerce' ); ?></th>
    
    • And here also, all this blocks at line 50 to 63 (to remove):
    <tfoot>
        <?php
            if ( $totals = $order->get_order_item_totals() ) {
                $i = 0;
                foreach ( $totals as $total ) {
                    $i++;
                    ?><tr>
                        <th class="td" scope="row" colspan="2" style="text-align:<?php echo $text_align; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
                        <td class="td" style="text-align:<?php echo $text_align; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
                    </tr><?php
                }
            }
        ?>
    </tfoot>
    

    2.Template emails/email-order-items.php.

    • Where you will remove this block at line 59:
    <td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
    

    So you will get this:

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改