Revert "Long floats convert to strings with chars like "E". Let's format to precision setting to avoid this."
This reverts commit 1ac8f6c272
.
This commit is contained in:
parent
7af6c2f55e
commit
004e58c8b8
|
@ -285,18 +285,14 @@ function wc_format_decimal( $number, $dp = false, $trim_zeros = false ) {
|
|||
$number = preg_replace( '/[^0-9\.,-]/', '', wc_clean( $number ) );
|
||||
}
|
||||
|
||||
if ( false === $dp && '' === $number ) {
|
||||
return '';
|
||||
if ( false !== $dp ) {
|
||||
$dp = intval( '' === $dp ? wc_get_price_decimals() : $dp );
|
||||
$number = number_format( floatval( $number ), $dp, '.', '' );
|
||||
} elseif ( is_float( $number ) ) {
|
||||
// DP is false - don't use number format, just return a string in our format.
|
||||
$number = wc_clean( str_replace( $decimals, '.', strval( $number ) ) );
|
||||
}
|
||||
|
||||
if ( false === $dp ) {
|
||||
$dp = wc_get_rounding_precision();
|
||||
} elseif ( '' === $dp ) {
|
||||
$dp = wc_get_price_decimals();
|
||||
}
|
||||
|
||||
$number = number_format( floatval( $number ), $dp, '.', '' );
|
||||
|
||||
if ( $trim_zeros && strstr( $number, '.' ) ) {
|
||||
$number = rtrim( rtrim( $number, '0' ), '.' );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue