Pierre-max Halldegare
Pierre-max Halldegare

Reputation: 63

Remove subtotal from confirmation mail woocommerce

I want to remove total and subtotal from woocommerce new order mail. This code works for total but subtotal is still displayed.

add_filter( 'woocommerce_get_order_item_totals', 'reordering_order_item_totals', 10, 3 );
function reordering_order_item_totals( $total_rows, $order, $tax_display ){
    $shipping = $total_rows['line_subtotal'];
    $order_total = $total_rows['order_total'];

    unset($total_rows['line_subtotal']);
    unset($total_rows['order_total']);


    return $total_rows;
}

I tried ['line_subtotal'], ['order_subtotal'], ['subtotal'] do you know its name?

Thank you a lot

Upvotes: 2

Views: 727

Answers (1)

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

please try below code in functions.php file

 add_filter( 'woocommerce_get_order_item_totals', 'reordering_order_item_totals', 10, 3 );
function reordering_order_item_totals( $total_rows, $order, $tax_display ){
    $shipping = $total_rows['cart_subtotal'];
    $order_total = $total_rows['order_total'];

    unset($total_rows['cart_subtotal']);
    unset($total_rows['order_total']);


    return $total_rows;
}

Upvotes: 2

Related Questions