Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Mayor pain in the ass


Recommended Posts

Fisrt sory but my english is bad, but i try it to tell them whats going wrong


In Chile my country we using pesos this peso don't use decimal

Explain: everething cost an exact value 200, 205, 200 without decimal


Thas is why i seting the oscommerce for not using decimal with my currency


The problem is i enter the value of all my products in dollar the chanche of that is 618 and the tax for my country is 19%


The oscommerce give me this




50x1,19=60x618=$37.080 But this is wrong


the real value is:



in less words the problem is in the formula, the formula round the values until i need to do


the correct formula is




where i can chanche this i look for everithing and everithing dosent work.




Link to comment
Share on other sites

The tax calculation is done in the tax class.


There is also a tep_round function which you will find in general.php

Mark Evans

osCommerce Monkey & Lead Guitarist for "Sparky + the Monkeys" (Album on sale in all good record shops)



Software is like sex: It's better when it's free. (Linus Torvalds)

Link to comment
Share on other sites

I try to explain in better way


Friends I have a problem that already clears the dream to me and is the following one.


I have a computer article store www.sym.cl

To fix my sale prices I use of base the dollar for my catalogue, I explain the entrance of products I do them in dollar since this facilitates at the time of changing the values to me of products according to the type of change, thus obvious I do not have to change 1 by one the products.


In summary the entrance I do it in dollars and the predetermined currency Pesos I fit the type of change where 618 Pesos = reason why 1 dollar is = to 618 this since the entrance is in dollars but the unfolding of the value in the site must be in Pesos, now I detail to the problem the problem to them is that the calculations me do oscommerce of incorrect form if I request to him that it does not use decimal in the change currency:


Example: I articulate x 50USD$ x 19% IVA = 59,5 xs 618(type of change) = $36,771 this would be the correct value.


But oscommerce makes following when eliminating of the unfolding of the prices the 2 decimal:


I articulate x 50USD$ x 19% IVA = 60 xs 618(tipo of change) = $37,080 Which is absolutely incorrect


Dice to that the site clears in a previous step to the suitable one. oscommerce single shows the correct value to me if fixed two decimal for the unfolding of prices but this are not a solution since in my country this does not, produce confusion so that all the values are exact, I can either pass the whole catalogue to Pesos since if the dollar changes in 1 unit I must change all values 1 by 1 and the idea is single to change the type of change.


Then my question is: some exists form of which it can publish formulates it of I calculate so that I calculate deploys with decimal but final of the value without and that of of correct form the value. Sincerely its aid would be very valuable and would serve as a contribution for all the stores that use the dollar as currency bases to fix prices but that they sell mainly in national currency if the currency does not have decimal. I am really sure that here it will find aid and thanks


Really to explain this in english is dificult to me beacause i undertunding if i readit but in 50% if i typed for me lol


Salu2 From Chile Marcelo

Link to comment
Share on other sites

I found this something to do with that?


// Calculates Tax rounding the result 
 function tep_calculate_tax($price, $tax) { 
   global $currencies; 

   return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); 


Link to comment
Share on other sites



As Mark stated, there is a function called 'tep-round()', and you have found where it is called.


/catalog/includes/functions/general.php - lines 284 to 303


// Wrapper function for round()
 function tep_round($number, $precision) {
   if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) {
     $number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1);

     if (substr($number, -1) >= 5) {
       if ($precision > 1) {
         $number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1');
       } elseif ($precision == 1) {
         $number = substr($number, 0, -1) + 0.1;
       } else {
         $number = substr($number, 0, -1) + 1;
     } else {
       $number = substr($number, 0, -1);

   return $number;



Link to comment
Share on other sites



I'm no PHP guru, but following the code in tep_round() function, it appears to me that if there is no decimal point, then the number simply gets returned, no rounding ??


What do others say ??



Link to comment
Share on other sites


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

  • Create New...