If this is your first visit, check our documentation. To post, register or login.
Forums / Bug Reports / Currency problem using comma as decimal point (shop in europe)

Currency problem using comma as decimal point (shop in europe)

Locked

Started by edveldman on 21 Sep 2007, 8:43 PM · Views: 13,251

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
21 Sep 2007, 8:43 PM
#1
edveldman avatar

edveldman

New Zenner

Join Date:
May 2007
Posts:
3
Plugin Contributions:
0

Currency problem using comma as decimal point (shop in europe)

I'm having a problem using comma as decimal point.
All price are displayed corectly but when a customer has a Gift Certificate and is trying to enter a value in Apply Amount: he has to use a point as decimal point.

Any ideas how to solf this problem???

21 Sep 2007, 10:31 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Currency problem using comma as decimal point (shop in europe)

Edit your /includes/modules/order_total/ot_gv.php file and add a comma into the list of allowed characters, like this:```
// clean out negative values and strip common currency symbols
$_SESSION['cot_gv'] = preg_replace('/[^0-9.%[B],[/B]]/', '', $_SESSION['cot_gv']);

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Sep 2007, 2:50 PM
#3
edveldman avatar

edveldman

New Zenner

Join Date:
May 2007
Posts:
3
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

Thanks DrByte,
did help a little, can use comma now, but comma is not beeing used as decimal point. When I enter 12,50 it is beeing treaded as 12,00.

Any sugestions.

18 Jan 2009, 3:36 PM
#4
kookiewookie avatar

kookiewookie

New Zenner

Join Date:
Jun 2006
Posts:
75
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

THIS MESSAGE: Thanks DrByte,
did help a little, can use comma now, but comma is not beeing used as decimal point. When I enter 12,50 it is beeing treaded as 12,00.
Any sugestions.

IS NOT CORRECT.

IF I apply the change of code & you enter 4,50 as to be used amount IT is treated as 450 !!!!

I keep searching this forum for a FIX for there must be many EU stores that have this problem becuase in most EU countries decimal is a , and thousands separated with a . SO
4,500 is really 4 euro's and 50 cents
4.500.00 = 4 million 500thousand.

Any one got the right fix??

Thanks!

KW

18 Jan 2009, 3:54 PM
#5
kookiewookie avatar

kookiewookie

New Zenner

Join Date:
Jun 2006
Posts:
75
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

Alright....
WE switched the currency setting to NON EU defaults.
so: decimals als separated with a dot (.)
and thousands with a ,

AND in ot_gv:
// clean out negative values and strip common currency symbols
$_SESSION['cot_gv'] = preg_replace('/[^0-9.%],/', '', $_SESSION['cot_gv']);
// and now replace a , in a dot when someone enters 10,20 instead of 10.20
$_SESSION['cot_gv'] = str_replace(array(','), '.', $_SESSION['cot_gv']);

SO it does not matter anymore , user can enter: 12,30 and 12.30
and the system calculates fine now.
Again: thumb down for this fix for we needed to switch the decimal separator....

24 Mar 2009, 3:44 PM
#6
angeljusto avatar

angeljusto

New Zenner

Join Date:
Jan 2009
Posts:
5
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

Here is my "solution" (the real solution would be not to need a solution, woudn't it?):

First, add this function to ot_gv.php. Just copy and paste the code between two of the existing functions (methods in fact):

// change the eropean separators for the US ones
function floatvalue($value) {
     return floatval(preg_replace('#^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$#e', "str_replace(array('.', ',', \"'\", ' '), '', '\\1') . '.\\4'", $value));
} 

Then find this line:

 $_SESSION['cot_gv'] = preg_replace('/[^0-9.%]/', '', $_SESSION['cot_gv']);

And change it for this one (I just added the comma as other ones did):

// comma added to avoid being stripped
    $_SESSION['cot_gv'] = preg_replace('/[^0-9.,%]/', '', $_SESSION['cot_gv']);

Then, finally, apply our new function. You have to apply it after the line you have changed above and before this one:```
$_SESSION['cot_gv'] = abs($_SESSION['cot_gv']);


Just copy and paste:

// apply the function floatvalue() to replace commas by dots in decimal places
$_SESSION['cot_gv'] = $this->floatvalue($_SESSION['cot_gv']);


I got the function floatvalue() from a contributor on the php site:
[http://es2.php.net/floatval](http://es2.php.net/floatval)
17 Jul 2010, 4:43 AM
#7
jolion avatar

jolion

New Zenner

Join Date:
Mar 2010
Posts:
21
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

I still have the problem in gv-send. When entering the amount of the gv, I must use the dot instead of comma. I run an EU shop and I want de comma as separator which is the standard for Euro's.

In modules/pages/gv_send/header_php.php I have tried all possibilities in line 85 and line 100, placing a comma, replace the dot etc. Though something changed, I still have not the wished result.

Yet I'm through all the possibilities and need some help. Is there a code available like the code for ot_gv.php?

Any help is welcome and thanks in advance!

José

24 Jul 2010, 5:32 AM
#8
jolion avatar

jolion

New Zenner

Join Date:
Mar 2010
Posts:
21
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

Is this thread still alive?

Or should I open a new thread for my point-comma problem in the currency field of gv-send?

24 Jul 2010, 6:08 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Currency problem using comma as decimal point (shop in europe)

jolion:

Is this thread still alive?

Or should I open a new thread for my point-comma problem in the currency field of gv-send?
The answer to your problem is: it's complicated.
In the short term, use the decimal point as the decimal point, instead of a comma.
In the long term, a fix may come one day.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

24 Jul 2010, 10:56 AM
#10
jolion avatar

jolion

New Zenner

Join Date:
Mar 2010
Posts:
21
Plugin Contributions:
0

Re: Currency problem using comma as decimal point (shop in europe)

Thanks for your reaction, DrByte!

So there's no solution yet, helas. Then I shall tell the costumer in a short text to use the point instead of the comma in the amount field of the gv-send form.

I hope the fix coming soon!

But maybe you know which files are involved for displaying the amount, I could try myself. Not that I pretend I'm a star in PHP but I can try anyway.