If you want to have this change on all email notifications, you will use the following code, that will display the gran total (without displayed taxes) and the taxes in a separated new row:
add_filter( 'woocommerce_get_order_item_totals', 'insert_custom_line_order_item_totals', 10, 3 );
function insert_custom_line_order_item_totals( $total_rows, $order, $tax_display ){
// Only on emails notifications
if( ! is_wc_endpoint_url() ) {
// Change: Display only the gran total amount
$total_rows['order_total']['value'] = strip_tags( wc_price( $order->get_total() ) );
// Create a new row for total tax
$new_row = array( 'order_tax_total' => array(
'label' => __('BTW:','woocommerce'),
'value' => strip_tags( wc_price( $order->get_total_tax() ) )
) );
// Add the new created to existing rows
$total_rows += $new_row;
}
return $total_rows;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
If you want to target only the "Customer invoice" email notification, instead you will need to make changes on the template emails/email-order-details.php
overriding it through your theme.
Please read first the documentation: Template structure & Overriding templates via a theme
Once you have copied emails/email-order-details.php
template file to your theme's folder, open/edit it.
On line 64 after:
$totals = $order->get_order_item_totals();
Add the following:
// Only Customer invoice email notification
if ( $email->id === 'customer_invoice' ):
// Change: Display only the gran total amount
$totals['order_total']['value'] = strip_tags( wc_price( $order->get_total() ) );
// Create a new row for total tax
$new_row = array( 'order_tax_total' => array(
'label' => __('BTW:','woocommerce'),
'value' => strip_tags( wc_price( $order->get_total_tax() ) )
) );
// Add the new created to existing rows
$totals += $new_row;
endif;
Tested and works too…