Use of rounded ammounts to avoid problems with .and, (euro)

Archived from the Web Auction Discussion forum.

manskie — Mon Oct 06, 2008 6:19 am

I changed the used currency from dollar to euro but now I encounter problems with not-rounded bids.

If somebody wants to bid 5 euro and changes the default 5.00 to 5,00 (which is the proper annotation in the Netherlands) the bid is taken as 500 euro’s instead of 5 euro’s

Is there an easy way to avoid this, or to change the function of , to . ????

Maybe a check for a comma in the entered field and autochange it to dot.

In my auction ist very unlikely to have bids above 1000 euro


shannah — Mon Oct 06, 2008 10:23 am

Ahh.. good question. I’m scouring the web to find the best practice for handling this. I’m sure it’ll be a simple fix, but I want to do some research on it first.

-Steve


manskie — Tue Oct 07, 2008 6:07 am

This is a very simple solution that seems 2 work 4 me (no guarantees):

In the autions\bid.php on line 10 ther is a preg_replace statement which I looked up at php.net. It filters out the unwanted chars and put them in a given format.

I changed this:

$amount = floatval(preg_replace(‘/[^.0-9]/’, ‘’,$_POST[’–bid-amount’]));

in:

$amount = floatval(preg_replace(‘/[^.,0-9]/’, ‘’,$_POST[’–bid-amount’]));

So I added a comma there. If I enter 5,00 it is regarded as 5 euro ….


Karonthe — Mon Nov 10, 2008 12:49 am

There is still another place where currencies are shown up, actions/watch_list.php, as a result of this part of a sql query:

select p.product_id, p.product_name, concat(‘$‘,format(high_bid,2)) as high_bid, high_bidder from products p…

I’ve changed it to show the euro symbol:

select p.product_id, p.product_name, concat(format(high_bid,2),’ \€’) as high_bid, high_bidder from products p

… but don’t know how to make it show the decimal point and thousands in an easy way. Any idea?