4

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.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Shilpi Jaiswal
  • 1,178
  • 2
  • 12
  • 27
  • Can't you just override the email template and remove the price column? – Kris Sep 11 '17 at 08:19
  • I have already overrided the template into my theme, but price coming from the code which I mentioned above , I can't find HTML which I can remove to remove price column – Shilpi Jaiswal Sep 11 '17 at 08:28
  • You should search for the strings already showing up in the email right now within the theme. The email template should be present in the theme or the plugin itself. You will be able to override the template as required. – Kris Sep 11 '17 at 08:30
  • I have tried in all possible ways to search for nearby strings in the email, but no success, only thing that I found I can remove whole product list row by removing above mentioned code but not only price column. – Shilpi Jaiswal Sep 11 '17 at 09:18

2 Answers2

10

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

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
4

You have two files to copy, email-order-details.php and email-order-items.php. These two files contains what you want to be removed. email-order-details.php has the <th> tag or the header of the table. And email-order-items.php has the <td> tags. Please check these files out.

Reigel Gallarde
  • 64,198
  • 21
  • 121
  • 139