Rearrange order detail totals on WooCommerce email notifications Rearrange order detail totals on WooCommerce email notifications wordpress wordpress

Rearrange order detail totals on WooCommerce email notifications


Using a custom function hooked in woocommerce_get_order_item_totals filter hook, will allow to reorder item totals as expected:

add_filter( 'woocommerce_get_order_item_totals', 'reordering_order_item_totals', 10, 3 );function reordering_order_item_totals( $total_rows, $order, $tax_display ){    // 1. saving the values of items totals to be reordered    $shipping = $total_rows['shipping'];    $order_total = $total_rows['order_total'];    // 2. remove items totals to be reordered    unset($total_rows['shipping']);    unset($total_rows['order_total']);    // 3 Reinsert removed items totals in the right order    $total_rows['shipping'] = $shipping;    $total_rows['order_total'] = $order_total;    return $total_rows;}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works.

enter image description here