I am using Woocommerce and want to display the tax ("incl. tax") in a seperate table row line above the totals(in cart and checkout), instead of right behind the totals in the same line like it is by default. I found this
add_filter('woocommerce_get_order_item_totals', 'dks_tax_new_line');
function dks_tax_new_line($total_rows)
{
//Define order total again without the (Includes %s) label
$total_rows['order_total']['value'] = $this->get_formatted_order_total();
//Make an array with tax
$taxes = [];
foreach ($this->get_tax_totals() as $code => $tax)
{
$taxes[] = sprintf('%s', $tax->formatted_amount);
}
//Add the tax row to the array that get_order_item_totals() outputs
$total_rows['tax_line'] = [
'label' => 'Herfra 25% Moms:',
'value' => sprintf(implode(', ', $taxes)),
];
return $total_rows;
}
But it doesn't work. Can anyone help? Thanks!