Format the price

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

I the last question that I make to this forum, I forgot some useful information to complete my question.

When a item price ends with one "0" or two "00", in the review page and the order page, the totalprice don't show the price with these numbers, for example, I put in the database file this item price "234.950" to be correct this number showld appear completely in the review page as the totalprice, but like I said, it only appears like this "234.95", and I want to display the complete number.

Tanks In advance

-- Manuel Tavares (mar114@hotmail.com), July 07, 1999

Answers

Hi, You have to change the code in the "smart.cgi" file that rounds off the price. Look for these lines.

sub round { my $number = shift; $number = int($number * (10 ** 2) + .5) / (10 ** 2); return $number; }

You have to change to:

$number = int($number * (100 ** 2) + .5) / (100 ** 2);

You will have to find every formular and change it. There are in the tax and shipping and mail. You just have to change the numbers.

Look for these lines:

sub pad { my $number = shift; if (index($number,".") >= 0) { my($left,$right) = split(/\./,$number); if (length($right) == 0) { $number = $number . "00"; } elsif (length($right) == 1) { $number = $number . "0"; } } else { $number = $number . ".00"; } return $number; }

Change the "00" to "000" and change the "0" to "00" and change the ".00" to ".000". Just change the numbers that are in quote marks "0" not the others.

That should do it. Back up your file before you edit.

Jim

-- James L. Farmer (jim@team-blankets.com), July 07, 1999.


Moderation questions? read the FAQ