3

I have been searching and searching for literally 4 days now, how to remove the price from the emails that are being sent to both the customer and to the admin. I was able to remove the Subtotal and Total sections, and the heading for the price per product, but I cannot remove the physical Price cell in the table.

Below is the code I have adjusted, along with a screenshot of what the email looks like.

email_order_details.php

<?php
if ( ! defined( 'ABSPATH' ) ) {
 exit;
}

$text_align = is_rtl() ? 'right' : 'left';

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

<?php if ( ! $sent_to_admin ) : ?>
 <h2><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
<?php else : ?>
 <h2><a class="link" href="<?php echo esc_url( admin_url( 'post.php?post=' . $order->get_id() . '&action=edit' ) ); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
<?php endif; ?>

<div style="margin-bottom: 40px;">
 <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
  <thead>
   <tr>
    <th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Product', 'woocommerce' ); ?></th>
    <th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
   </tr>
  </thead>
  <tbody>
   <?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,
   ) ); ?>
  </tbody>
  <tfoot>
   <?php
    if ( $order->get_customer_note() ) {
     ?><tr>
      <th class="td" scope="row" colspan="2" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Note:', 'woocommerce' ); ?></th>
      <td class="td" style="text-align:<?php echo $text_align; ?>;"><?php echo wptexturize( $order->get_customer_note() ); ?></td>
     </tr><?php
    }
   ?>
  </tfoot>
 </table>
</div>

<?php do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

email_order_items.php

<?php
if ( ! defined( 'ABSPATH' ) ) {
 exit;
}

$text_align = is_rtl() ? 'right' : 'left';

foreach ( $items as $item_id => $item ) :
 $product = $item->get_product();
 if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
  ?>
  <tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
   <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; word-wrap:break-word;"><?php

    // Show title/image etc
    if ( $show_image ) {
     echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), 'thumbnail' ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item );
    }

    // Product name
    echo apply_filters( 'woocommerce_order_item_name', $item->get_name(), $item, false );

    // SKU
    if ( $show_sku && is_object( $product ) && $product->get_sku() ) {
     echo ' (#' . $product->get_sku() . ')';
    }

    // allow other plugins to add additional product information here
    do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text );

    wc_display_item_meta( $item );

    // allow other plugins to add additional product information here
    do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );

   ?></td>
   <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 apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
  </tr>
  <?php
 }

 if ( $show_purchase_note && is_object( $product ) && ( $purchase_note = $product->get_purchase_note() ) ) : ?>
  <tr>
   <td colspan="3" 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 wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
  </tr>
 <?php endif; ?>

<?php endforeach; ?>

Screenshot

screenshot

Thank you.

Sudheesh R
  • 1,767
  • 3
  • 23
  • 43
joshualavers
  • 51
  • 1
  • 6
  • to remove the price from the letter, it needs to be removed from the checkout page and "thank you" page – Mykyta Dudariev Nov 16 '17 at 14:28
  • 1
    I have this done. The only issue I am having is the $0.00 still being there. I have attempted multiple different things, and none of them have worked. – joshualavers Nov 16 '17 at 14:34
  • Have you overridden the templates correctly in your theme? https://docs.woocommerce.com/document/template-structure/ This solution should work, although it seems you've followed it correctly https://stackoverflow.com/questions/46150455/customize-orders-details-table-in-woocommerce-email-notifications – Matts Nov 16 '17 at 23:07
  • @joshualavers Oh hi Mark! – MattyK14 Dec 19 '17 at 14:55

2 Answers2

3

Modify this template \order\order-details-item.php to remove the item price.

Comment out the following code to remove the price from showing.

<td class="woocommerce-table__product-total product-total">
    <?php echo $order->get_formatted_line_subtotal( $item ); ?>
</td>
Andrew Schultz
  • 4,092
  • 2
  • 21
  • 44
0

Modify template

woocommerce/emails/email-order-items.php

You can comment out:

<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( $order->get_formatted_line_subtotal( $item ) ); ?>
        </td>
Roger Gajraj
  • 523
  • 4
  • 12