Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

prices rounded but showing correct decimal places (2)


nat8100

Recommended Posts

Posted

Hi..

 

When I put a price in a product and press 'preview' it just shows '0' in the preview, not even the ?.

 

Then on the catalog side it rounds the product to the nearest pound, yet showign the correct decimal places..

 

i.e. ?32.99 would show as ?33.00

and ?32.49 would show as ?32.00

 

The decimals are correct in the currencies and in the configuration>my store.

 

I think the rounding is done in the file includes/functions/general.php:

 

// 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;
 }

 

But I don't really know PHP and have come unstuck for options to try.. any suggestions? anyone had the same problem? Seen similar problems but usually to do with the decimal places. Thanks in advance!

Archived

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

×
×
  • Create New...