0

I am customizing k2 store front end and I need some help with currency formatting.

My code is:

<span>Tax: <?php echo $item->tax ?></span>
<span>Price without tax: <?php echo $item->price; ?></span>

Don't know why but this code outputs:

Tax: 11
Price without TAX: 50.00000

I would like to output:

Tax: 11,00 EUR
Price without tax: 50,00 EUR

I found some hints for formatting values in PHP but I was not able to implement it in my case. I have a poor PHP knowledge.

Shaz
  • 2,647
  • 2
  • 35
  • 45
TheAgent
  • 11
  • 1
  • 4

1 Answers1

0

how about using php's money_format function? In this case a similar SO post seems to have an answer

setlocale(LC_MONETARY, 'nl_NL.UTF-8');
$amount = money_format('%(#1n', $amount);
echo $amount;

you could put this into a function like

function to_euro($input){
    setlocale(LC_MONETARY, 'nl_NL.UTF-8');
    return money_format('%(#1n', $input);
}

then use it like

echo to_euro($item->tax);
Community
  • 1
  • 1
dotty
  • 40,405
  • 66
  • 150
  • 195