[Checkout] wrong Price, total amount is calculated wrong

kamivore

Joined: 2006-04-13
Posts: 3
Posted: Tue, 2006-04-18 21:24

checkout_v0.1.14

Gallery-Version = 2.1 Kern 1.1.0
PHP-Version = 4.4.2 cgi
Webserver = Apache/1.3.33 (Unix)
Datenbank = mysql 4.0.25-standard-log, lock.system=flock
Werkzeuge = ArchiveUpload, Exif, Getid3, NetPBM, SquareThumb, Thumbnail, Gd
Beschleunigung = none, none
Betriebssystem = Linux infong 2.4 #1 SMP Wed Jan 18 14:53:29 CET 2006 i686 unknown
Standard-Motiv = matrix
Sprache = de_DE
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; Crazy Browser 3.0.0 Beta2)

Greetings from Germany - sorry for my english....

There is a problem with the total at the second step of checkout.
A price like 0,49 is shown in the 2 step as 0.00 (every Number after the , is converted to 00).
I think the reason for this problem is conected with the admin of checkout.
When I´m entering a price like 1.55 it will be converted to 1,55 after saving the changes.

I think the checkout module needs a price with a . but I can´t save this in the admin.

Thanks for your help

 
nicotjo

Joined: 2006-04-22
Posts: 8
Posted: Sun, 2006-04-23 09:45

Hi,
Maybe I can add some information on this one (have no solution for it though). Seems I have the same problem. On my local system (WinXP, Apache) it works fine. On the Linux (Apache) system the ',' and '.' are mixed up.

Checked the database table pluginparametermap (where prices are stored) and found 1.2 on the WinXP installation and 1,2 in the Linux system. It confirms kamivore's assumption that it goes wrong when inserting the prices.
Maybe it works on my WinXP system because the localisation does not work on that installation?! Got the following message in my Site Admin screen: Your webserver does not support localization. Please instruct your system administrator to reconfigure PHP with the gettext option enabled.
Well it might give some clues to the one who is able to solve this problem.
Regards!

 
nicotjo

Joined: 2006-04-22
Posts: 8
Posted: Sun, 2006-04-23 10:36

Hi,
Could not wait for a definitive solution, so this is the quick and yes, the dirty one...
Modify modules/checkout/Admin.inc, line 77 into
$newprice = floatval($form['price'][$i]);
And with this q&d solution you should enter prices with a '.' as decimal point!

[Be aware that this is not THE solution[/b] The solution itself might be more complex, since 'locale' is involved here -> Dutch & German have a ',' as a decimal 'point' while US has a '.'.

By the way, notice that the 'Postage amount' can be written with '.' and ',', both syntax will work! Well, this need some rework. Can someone help on this one?

 
Gerald Pineau

Joined: 2006-03-27
Posts: 3
Posted: Sun, 2006-04-23 20:51

hi,

I have the same problem.
But this not solve it.
all the price with a "." are replaced by a "," when I save. And when I save again or when I return in checkout admin, the price is downgraded to the lower integer. For exemple, 0.20 become 0.
I'm using Gallery in french.

Where is the problem ? In gallery or in my apache/php config?

Thanks for your help.
Gérald.

 
smith17

Joined: 2006-04-26
Posts: 2
Posted: Thu, 2006-04-27 16:01

Try using
$newprice = str_replace(",",".",$form['price'][$i]);
instead of lines 74-78.
This is also an Ugly Terrible Horrible Hack, but at least it works for me.
This all definitely has something to do with server locales, but I can't figure out how :(

 
turnbulm

Joined: 2004-10-03
Posts: 431
Posted: Thu, 2006-04-27 18:54

I just noticed this post - somehow I missed it when it first came along.

The reason for this problem is that when the modules were written, Gallery did not support a "float" storage type in the database - it was either integer or string. As a result I had to hack the values in with some nasty PHP type casting, and I'm not surprised to hear that it breaks when you're not using '.' as the separator.

I will go back and look at this again, in the hope that I can now store non-integer values directly in the database!

 
kamivore

Joined: 2006-04-13
Posts: 3
Posted: Thu, 2006-05-04 22:12

Thank you - your Terrible Horrible Hack works perfect ;)
Best Regards from Germany

 
nicotjo

Joined: 2006-04-22
Posts: 8
Posted: Fri, 2006-05-05 18:57

Thanks! - The hack works for me too!

 
Gerald Pineau

Joined: 2006-03-27
Posts: 3
Posted: Sat, 2006-05-06 06:48

thanks, it works for me too :-)