Results 1 to 10 of 10
  1. #1
    Join Date
    May 2007
    Posts
    3
    Plugin Contributions
    0

    Default 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???

  2. #2
    Join Date
    Jan 2004
    Posts
    65,657
    Blog Entries
    7
    Plugin Contributions
    240

    Default 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']);
    .

    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.

  3. #3
    Join Date
    May 2007
    Posts
    3
    Plugin Contributions
    0

    Default 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.

  4. #4
    Join Date
    Jun 2006
    Posts
    75
    Plugin Contributions
    0

    red flag 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

  5. #5
    Join Date
    Jun 2006
    Posts
    75
    Plugin Contributions
    0

    Default 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....

  6. #6
    Join Date
    Jan 2009
    Posts
    4
    Plugin Contributions
    0

    Default 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

  7. #7
    Join Date
    Mar 2010
    Posts
    21
    Plugin Contributions
    0

    Default 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ť

  8. #8
    Join Date
    Mar 2010
    Posts
    21
    Plugin Contributions
    0

    Default 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?

  9. #9
    Join Date
    Jan 2004
    Posts
    65,657
    Blog Entries
    7
    Plugin Contributions
    240

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

    Quote Originally Posted by jolion View Post
    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.

  10. #10
    Join Date
    Mar 2010
    Posts
    21
    Plugin Contributions
    0

    Default 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.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 19 Oct 2012, 08:17 AM
  2. Using 4 decimal places (Currency) whilst displaying only 2?
    By guyp in forum Managing Customers and Orders
    Replies: 11
    Last Post: 29 Sep 2010, 11:19 AM
  3. Comma as decimal separator in quantity
    By cricri in forum Basic Configuration
    Replies: 2
    Last Post: 6 Dec 2009, 08:07 PM
  4. decimal point problem
    By rajeev83 in forum General Questions
    Replies: 4
    Last Post: 26 Sep 2006, 05:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR