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???
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:
Code:
// clean out negative values and strip common currency symbols
$_SESSION['cot_gv'] = preg_replace('/[^0-9.%,]/', '', $_SESSION['cot_gv']);
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.
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
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....
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):
Code:
// 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:
Code:
$_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):
Code:
// 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:
Code:
$_SESSION['cot_gv'] = abs($_SESSION['cot_gv']);
Just copy and paste:
Code:
// 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
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é
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?
Re: Currency problem using comma as decimal point (shop in europe)
Quote:
Originally Posted by
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.
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.