If I set the format settings (ubercart configuration)
. for thousands
, for decimals

The javascript function doesn't work anymore, it inserts a bid price that couldn't be placed.

Is their some hardcoded formatting set?

TIA,
Fossie

Comments

Garrett Albright’s picture

Assigned: Unassigned » Garrett Albright

Aha. When the JavaScript functions check values, they do so by stripping all characters out of a number except for digits and the period character, then converting that number using JavaScript's standard number conversion functions (which expect the period to be the decimal point). So:

"1,234.56" => "1234.56" => 1234.56 as a number - correct
"1.234,56" => "1.23456" => 1.23456 as a number - incorrect

I will have to modify the JavaScript a bit to deal with this circumstance of using the comma as the decimal point. Thanks for bringing it to my attention. Please stick around because I may have some patches I'll ask you to test in the future.

Garrett Albright’s picture

Status: Active » Closed (fixed)
Garrett Albright’s picture

Status: Closed (fixed) » Active

Oops. Closed the wrong issue.

Garrett Albright’s picture

Hmm. It's interesting because it looks like Ubercart itself is not very tolerant about values which are not formatted with a period as the decimal point in its input; see uc_product_validate() in uc_product.module (lines 632-665). But I made some tweaks and now UC Auction should be more tolerant for values formatted with different decimal and thousands separators - more tolerant than Ubercart itself, even. But please test it when you download the new one.

fossie’s picture

Thx,

I'll try it as soon as possible and keep you informed.

Fossie

Garrett Albright’s picture

fossie, have you been able to give this a try yet?

rsm08’s picture

I works I can tell you.

But mind you there's no validation for the amounts entered. So if a user on a system that's configured in "reverse" ("." for thousands and "," for decimal) enters fx.:

10.50

The system will interpret it as

1050

I don't know if this will be the same if 10,50 is entered when running with "normal" decimal-configuration.

Regarding Ubercart's stubborn validaton function that ignores "reverse" decimal-configuration and will never accept "," as decimal separator, I put this code into a custom validation function and put in my own amount validation:

   // Remove the price format error set by the default uc_product_form_validate function that we can't prevent from being executed
    $errors = form_get_errors();                                                   
    form_set_error(NULL, '', True);    
    unset($_SESSION['messages']['error']);	                                       
    foreach (array_keys($errors) as $key) {
	if ($key != 'list_price' && $key != 'sell_price') {
		form_set_error($key, $errors[$key]);
            }
   }

Maybe someone can use it or have a better solution..

Garrett Albright’s picture

Status: Active » Fixed

I'll close this one then.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.