Posted by fossie on January 27, 2009 at 11:09pm
Jump to:
| Project: | Ubercart Auction |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Garrett Albright |
| Status: | closed (fixed) |
Issue Summary
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
#1
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.
#2
#3
Oops. Closed the wrong issue.
#4
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.
#5
Thx,
I'll try it as soon as possible and keep you informed.
Fossie
#6
fossie, have you been able to give this a try yet?
#7
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..
#8
I'll close this one then.
#9
Automatically closed -- issue fixed for 2 weeks with no activity.