Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Format the price after exchange rate conversion


HairyJim

Recommended Posts

Hi all,

 

When a price is converted from the default to the new currency teh price can loo ugly.

 

I want the price to be formatted so a output of ?5.33 becomes ?5.30

 

I have the code to format this correctly but I cannot find the right place to put it.

 

$remainder = $number%10; //Modulus .. handy operator.
   if ($remainder < 5 & $remainder != 0 & $remainder != 5) {
       $number = $number-$remainder;
   } elseif ($remainder > 5 & $remainder != 0 & $remainder != 5) {
       $number = $number+(10-$remainder);
   }

 

Cheers

jim

Link to comment
Share on other sites

Do you really want to do this.

 

Most people know that if on a site which defaults to $ that when they convert they get strange amounts, it's not that unusual.

 

Not something I would worry about, as long as your prices are correct in your default currency.

Link to comment
Share on other sites

Do you really want to do this.

 

Most people know that if on a site which defaults to $ that when they convert they get strange amounts, it's not that unusual.

 

Not something I would worry about, as long as your prices are correct in your default currency.

 

 

Yes, this is not my decision. My employer wants it reformatting.

Link to comment
Share on other sites

Yes, this is not my decision. My employer wants it reformatting.

 

Hmmm, tricky one this.

 

What I would do is create a function with your code in it

 

function RoundCurrency($Price){

blah blah your code

}

 

save that in functions/general.php

 

the tricky part is where to apply it. I would use a GREP tool to find all locations where the function tep_add_tax is being called, knowing that has something to do with displaying prices, then add your function round about there

Link to comment
Share on other sites

or in the classes/currencies.php

 

which defines the currencies class the function format

 

look a promising candidate as it handles the output for each selected currency, maybe just put your function in there and you wont have to worry about putting it elsewhere as that function already gets called in various places.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...