Viewing 8 replies - 1 through 8 (of 8 total)
  • You can override the email template files to your theme folder.

    Then remove this line of codes:

    <tfoot>
    	<?php
    		if ( $totals = $order->get_order_item_totals() ) {
    			$i = 0;
    			foreach ( $totals as $total ) {
    				$i++;
    				?><tr>
    					<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
    					<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
    				</tr><?php
    			}
    		}
    	?>
    </tfoot>

    That codes resides in:

    * emails/admin-cancelled-order.php
    * emails/admin-new-order.php
    * emails/customer-completed-order.php
    * emails/customer-invoice.php
    * emails/customer-note.php
    * emails/customer-processing-order.php

    I hope it helps.

    Thread Starter dg

    (@denizgezgin)

    Thanks for the answer, Kharis.
    But sadly, it does not work as I need it to. I tried this before, but this removes all the totals part from the mail. I must only remove the “subtotal” part.
    Any ideas?

    Thanks,

    Try this

    if ( $totals = $order->get_order_item_totals() ) {
    	$i = 0;
    	foreach ( $totals as $total ) {
    		$i++;
    
    		if( $total['label'] != 'Subtotal:') :
    
    		?><tr>
    			<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
    			<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
    		</tr><?php
    
    		endif;
    
    	}
    }

    Let me know how it works for you.

    Thread Starter dg

    (@denizgezgin)

    Hello again,
    Sorry, but this did not work. Actually nothing happened, site works fine with no errors, but subtotal is still there in the emails. I tried with different files (admin new order, customer processing order, etc.)
    I replaced the relevant part with the one you sent. Did I do wrong?

    I have tested on my end. It works. See this new order email notification screenshot.

    Here is full codes of admin-new-order.php

    <?php
    /**
     * Admin new order email
     *
     * @author WooThemes
     * @package WooCommerce/Templates/Emails/HTML
     * @version 2.0.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    ?>
    
    <?php do_action( 'woocommerce_email_header', $email_heading ); ?>
    
    <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ); ?></p>
    
    <?php do_action( 'woocommerce_email_before_order_table', $order, true, false ); ?>
    
    <h2><a href="<?php echo admin_url( 'post.php?post=' . $order->id . '&action=edit' ); ?>"><?php printf( __( 'Order #%s', 'woocommerce'), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
    
    <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
    	<thead>
    		<tr>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Product', 'woocommerce' ); ?></th>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
    			<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e( 'Price', 'woocommerce' ); ?></th>
    		</tr>
    	</thead>
    	<tbody>
    		<?php echo $order->email_order_items_table( false, true ); ?>
    	</tbody>
    	<tfoot>
    		<?php
    			if ( $totals = $order->get_order_item_totals() ) {
    				$i = 0;
    				foreach ( $totals as $total ) {
    					$i++;
    
    					if( $total['label'] != 'Subtotal:') :
    
    					?><tr>
    						<th scope="row" colspan="2" style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
    						<td style="text-align:left; border: 1px solid #eee; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
    					</tr>
    
    					<?php
    
    					endif;
    				}
    			}
    		?>
    	</tfoot>
    </table>
    
    <?php do_action( 'woocommerce_email_after_order_table', $order, true, false ); ?>
    
    <?php do_action( 'woocommerce_email_order_meta', $order, true, false ); ?>
    
    <?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
    
    <?php do_action( 'woocommerce_email_footer' ); ?>

    “I replaced the relevant part with the one you sent. Did I do wrong?”

    Can you post your full codes? So I can have a look.

    Thread Starter dg

    (@denizgezgin)

    Thanks Kharis for helping. This time I replaced the whole admin-new-order.php file with the code you shared. I don’t understand but it still is not working for me. Perhaps there is a conflict with the settings I’m using in WooCommerce, although it sounds highly unlikely.

    I think I can live with that, with subtotal showing up on the e-mails.

    Thanks though, for your time and interest in helping out. Much appreciated:)

    i need to remove payment method line from emails 🙁

    i tried Kharis Sulistiyono code and it is working

    just copy it to customer-processing-order.php NOT admin-new-order.php

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘removing subtotal line in E-Mails’ is closed to new replies.