CMS MADE SIMPLE FORGE

Products

 

[#10709] Price changing from dot to comma

avatar
Created By: TimdeBuurman (timdebuurman)
Date Submitted: Thu Oct 15 05:04:58 -0400 2015

Assigned To:
Version: 2.24.2
CMSMS Version: 2.2.1
Severity: None
Resolution: Awaiting Response
State: Closed
Summary:
Price changing from dot to comma
Detailed Description:
Hi,

After upgrade Products from 2.24.1 to 2.24.2 (I upgraded all other modules and
core to 1.12.1) the price changes from dot decimal to comma.

So after revisit the product I see in the price field 14,95 instead of 14.95
(ofcourse I filled in the price with dot)

So after saving again, the comma is ignored and it becomes 14

----
My CMSMS version is 1.12.1



History

Comments
avatar
Date: 2015-10-15 09:02
Posted By: Robert Campbell (calguy1000)

no problems here.
      
avatar
Date: 2015-10-15 14:04
Posted By: TimdeBuurman (timdebuurman)

Today I upgraded a second website and the same problem occured.
Can you tell me what extra information is needed to reproduce this?

Here my system information:



----------------------------------------------

Cms Version: [b]1.12.1[/b]

Installed Modules:

    CMSMailer: [b]5.2.2[/b]
    CMSPrinting: [b]1.0.5[/b]
    FileManager: [b]1.4.5[/b]
    MenuManager: [b]1.8.7[/b]
    FormBuilder: [b]0.8.1.1[/b]
    ModuleManager: [b]1.5.8[/b]
    News: [b]2.15.2[/b]
    Search: [b]1.7.13[/b]
    ThemeManager: [b]1.1.8[/b]
    TinyMCE: [b]2.9.12[/b]
    MicroTiny: [b]1.2.9[/b]
    CGExtensions: [b]1.49.9[/b]
    CGSmartImage: [b]1.20.3[/b]
    CGSimpleSmarty: [b]1.9.1[/b]
    CGEcommerceBase: [b]1.5.2[/b]
    CGPaymentGatewayBase: [b]1.3.1[/b]
    Cart2: [b]1.1.3[/b]
    FrontEndUsers: [b]1.29[/b]
    CustomContent: [b]1.10[/b]
    JQueryTools: [b]1.3.7[/b]
    Products: [b]2.24.2[/b]
    Orders: [b]1.16.5[/b]
    FRShipping: [b]1.2.3[/b]
    SelfRegistration: [b]1.9.2[/b]
    SisowGateway: [b]0.5.6[/b]
    DestinationBasedShippingWeight: [b]1.1.2[/b]
    MleCMS: [b]1.11.4[/b]
    CGContentUtils: [b]1.5.1[/b]
    Promotions: [b]1.2[/b]
    Cart: [b]1.10.1[/b]
    ListIt2: [b]1.4.1[/b]
    ListIt2uitschuif: [b]1.4.1[/b]
    Guestbook: [b]1.4_RC2[/b]
    SEOTools2: [b]1.2.1[/b]
    DestinationBasedShipping: [b]1.1.2[/b]
    TemplateExternalizer: [b]2.1.6[/b]
    Gallery: [b]2.0.2[/b]
    Cartlog: [b]0.0.1[/b]
    CGBlog: [b]1.13.1[/b]


Config Information:

    php_memory_limit: [b][/b]
    process_whole_template: [b][/b]
    max_upload_size: [b]32000000[/b]
    url_rewriting: [b]mod_rewrite[/b]
    page_extension: [b][/b]
    query_var: [b]page[/b]
    image_manipulation_prog: [b]GD[/b]
    auto_alias_content: [b]true[/b]
    locale: [b]nl_NL.UTF-8[/b]
    default_encoding: [b]utf-8[/b]
    admin_encoding: [b]utf-8[/b]
    set_names: [b]true[/b]


Php Information:

    phpversion: [b]5.4.36[/b]
    md5_function: [b]Aan[/b] (Waar)
    gd_version: [b]2[/b]
    tempnam_function: [b]Aan[/b] (Waar)
    magic_quotes_runtime: [b]Uit[/b] (Onwaar)
    E_STRICT: [b]2048[/b]
    E_DEPRECATED: [b]8192[/b]
    memory_limit: [b]256M[/b]
    max_execution_time: [b]90[/b]
    output_buffering: [b]4096[/b]
    safe_mode: [b]Uit[/b] (Onwaar)
    file_uploads: [b]Aan[/b] (Waar)
    post_max_size: [b]64M[/b]
    upload_max_filesize: [b]32M[/b]
    session_save_path: [b]Geen controle omdat 'open_basedir' actief is[/b]
    session_use_cookies: [b]Aan[/b] (Waar)
    xml_function: [b]Aan[/b] (Waar)
    xmlreader_class: [b]Aan[/b] (Waar)


Server Information:

    Server Api: [b]apache2handler[/b]
    Server Db Type: [b]MySQL (mysqli)[/b]
    Server Db Version: [b]5.6.12[/b]
Server Db Grants: [b]Er is een "GRAND ALL" permissie gevonden, alles lijkt
in orde.[/b]
    Server Time Diff: [b]Geen tijdverschil aangetroffen[/b]


----------------------------------------------

      
avatar
Date: 2015-10-16 05:54
Posted By: Rolf (rolf1)

Velden and I could reproduce this. 
Look for details in forum
http://forum.cmsmadesimple.org/viewtopic.php?p=324563#p324563
      
avatar
Date: 2016-02-03 08:18
Posted By: Thijs (Teezii)

Got the problem here as well

CMS Made Simple™ 1.12 “Pohnpei”
Products version : 2.24.2
      
avatar
Date: 2017-07-11 02:07
Posted By: TimdeBuurman (timdebuurman)

Hi, 

Same problem is now occuring now in CMSMS 2.2.1 with Products 2.26.8
      
avatar
Date: 2017-07-12 22:11
Posted By: Robert Campbell (calguy1000)

After extensive research, and a test script... I've found that:

a:  PHP is good at converting floating point values to locale specific strings
for display.
b:  PHP SUCKS at converting locale specific strings to floating point values.
so Products stores prices, weights, etc.  as floats internally instead of
strings.  as it should.
when using german/french/dutch/etc locales,  php will use , as a decimal
separator when displaying float values
PHP will not convert strings with a , as a decimal separator back to floats
properly.

So... I have to either:
a:  Convert everything to store strings (not gonna happen, way too slow, too
much work)
      or
b:  On form submit, try to convert the string entered in a locale specific
format (because it was printed in a locale specific format) back to a float
properly.

Suffice it to say:
a:  This is not a Products specific issue
b:  We're not the only ones to have this issue
c:  It will take more than a few minutes to resolve this.

Test script:
<?php
function test($in) {
    $out = gettype($in).' - '.$in."\n";
    return $out;
}

$x1 = 1.234; // native float
$x2 = '1.234'; // uses dot.
$x3 = '1,234'; // uses comma

setlocale(LC_ALL,'en_US.utf8');  // will use . as decimal separator when
displaying a double as a string
echo "TEST 1 - ".test($x1);    // works
echo "TEST 2 - ".test((float)$x2); // works
echo "TEST 3 - ".test((float)$x3); // fails
echo "TEST 4 - ".test(floatval($x2)); // works
echo "TEST 5 - ".test(floatval($x3)); // failes
echo "\n";

setlocale(LC_ALL,'fr_FR.utf8');   // now when converting a double to a string
will use , as decimal separator.
echo "TEST 1 - ".test($x1);   // works
echo "TEST 2 - ".test((float)$x2);  // works
echo "TEST 3 - ".test((float)$x3); // fails
echo "TEST 4 - ".test(floatval($x2)); // works
echo "TEST 5 - ".test(floatval($x3)); // fails
echo "\n";

      
Updates

Updated: 2017-10-15 16:55
state: Open => Closed

Updated: 2017-07-11 02:07
resolution_id: 11 => 10
cmsms_version_id: 30653 => 31153

Updated: 2015-10-15 09:02
resolution_id: => 11