Jump to content

Price notation adjustments remove (,00) everywhere

Paul de Cocq

Recommended Posts

Hi everyone,


I have to change the displayPrice notation if it is an round number like 99,00 i need to change that in: 99,-

But if it is a number like 99,95 it has to stay like that.


What i've tried:

And this works fine for plain prices in overviews or product.tpl's. But in Ajax related elements throughout the site it doesn't work (like the shopping cart at the top of website and if you update quantities in the shopping cart).

{convertPrice|regex_replace:'/[,.]0+$/':',-' price=$productPrice}

What I need:

to change something in the core files (or overwrite folder) so that the price notation changes everywhere correctly and the same. I found out that i need to change something in: classes->Tools.php (line: ~459 displayPrice function), and in the theme folder theme->js->tools.js so if anyone has an idea how to dot this i'd really appreciate!









Link to comment
Share on other sites

You can run the exact same regex using the php, just need to use preg_replace


So it'd be something like:

$price = preg_replace('/[,.]0+$/', ',-', $price);

For javascript you can just run regex's in the standard replace function

price = price.replace(/[,.]0+$/, ',-');

I'd recommend trying to switch the pattern to this though, just in case for whatever reason the price you're trying to convert doesn't stop directly at the price (maybe the currency symbol comes after or some such)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...