Ivan Milic - Networks expert Ivan Milic CEO Ivan Milic

Top Menu

× To post a question you must be signed in.

Trouble with decimal separator

02 Feb 2016 13:44 #436 by Prokop
Trouble with decimal separator was created by Prokop
Hi!

Thanks for an great extension.

Unfortunately, we have trouble updating prices with decimals in the latest 2 releases.

If we attempt to write a decimal number with comma or stop signs, the auto sale price goes nuts.

In short, it is not possible for me to input decimals as the systems neither likes comma nor stop sign separators. When an override is involved, it gets even more difficult.

I made this video to illustrate: sendvid.com/9hg4vr7p

cheers,
prokop

Please Log in or Create an account to join the conversation.

02 Feb 2016 18:22 #437 by Super User
Replied by Super User on topic Trouble with decimal separator
HI,

open wooc.php file , find this line:

$_num_sample = (1/2).'';

and replace it with :

$_num_sample = '0.0';

Please Log in or Create an account to join the conversation.

05 Feb 2016 12:13 #439 by Prokop
Replied by Prokop on topic Trouble with decimal separator
Hi!

I have no "wooc.php" on my system. I run Virtuemart. Could you provide me a similar fix for VM ?

cheers

Please Log in or Create an account to join the conversation.

05 Feb 2016 13:14 #440 by Super User
Replied by Super User on topic Trouble with decimal separator
Did you maybe activated German numbers option ? If yes turn it off.

If that is ok look for function:

function Getfloat($str) {
global $SETTINGS;
if($SETTINGS->german_numbers){
if(strstr($str, ".")) {
$str = str_replace(".", "", $str); // replace ',' with '.'
}
$str = str_replace(",", ".", $str);
}else{
if(strstr($str, ",")) {
$str = str_replace(",", "", $str); // replace ',' with '.'
}
}
return floatval($str);
};


modify it like this:

function Getfloat($str) {

return floatval($str);
};

Please Log in or Create an account to join the conversation.

15 Feb 2016 13:15 #452 by Prokop
Replied by Prokop on topic Trouble with decimal separator
Hi!

I do not understand what German numbers are or where to find that setting. Is it Virtuemart configuration ?

I searched my way to find the code you mentioned in vmexcellikeinput.php. Upon changing the code, I messed around to see if VMLEM accepted decimals. The component then started to randomly change the price of the shown products. See this vid for example: video

It changed about 30 products before I terminated the page. I then needed the table reconstructed from backup.

So my question is, what are German numbers and what do you think of this behaviour by VMLEM ?

Please Log in or Create an account to join the conversation.

15 Feb 2016 20:02 #456 by Super User
Replied by Super User on topic Trouble with decimal separator
That is when you set decimal separator to comma.

What is your database collation ?

Please Log in or Create an account to join the conversation.

16 Feb 2016 09:19 #459 by Prokop
Replied by Prokop on topic Trouble with decimal separator
Hi!

Thanks for the quick answer.

We use the danish currency, which carries the comma separator. The same system is used by the majority of the non-english speaking world: wiki on decimals

Our database collation is "utf8 - default collation"

Can you comment on how to correct our problem? We cannot correct prices as the system freaks out when inserting comma decimals.

Cheers,

Please Log in or Create an account to join the conversation.

17 Feb 2016 13:43 #463 by Super User
Replied by Super User on topic Trouble with decimal separator
Hi,

note that decimal option counts only for import/export . After you telling me that you need this for online editing ?

Please Log in or Create an account to join the conversation.

Time to create page: 0.085 seconds