Laurent Destailleur 4 lat temu
rodzic
commit
58eaef37d2
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3 1
      htdocs/core/lib/functions.lib.php

+ 3 - 1
htdocs/core/lib/functions.lib.php

@@ -4723,7 +4723,9 @@ function price2num($amount, $rounding = '', $option = 0)
 	// Convert value to universal number format (no thousand separator, '.' as decimal separator)
 	if ($option != 1) {	// If not a PHP number or unknown, we change or clean format
 		//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
-		$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount);
+		if (!is_numeric($amount)) {
+			$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount);
+		}
 
 		if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) {	// It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123
 			$amount = str_replace($thousand, '', $amount);