Use the price decimal separator to format product weight and dimensions

This commit is contained in:
Yordan Soares 2022-04-22 20:55:19 -04:00
parent 542f7ef918
commit d394572378
2 changed files with 6 additions and 3 deletions

View File

@ -181,7 +181,8 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_enqueue_script( 'jquery-ui-autocomplete' ); wp_enqueue_script( 'jquery-ui-autocomplete' );
$locale = localeconv(); $locale = localeconv();
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.'; $decimal_point = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$decimal = ( ! empty( wc_get_price_decimal_separator() ) ) ? wc_get_price_decimal_separator() : $decimal_point;
$params = array( $params = array(
/* translators: %s: decimal */ /* translators: %s: decimal */

View File

@ -345,14 +345,16 @@ function wc_format_localized_price( $value ) {
} }
/** /**
* Format a decimal with PHP Locale settings. * Format a decimal with the decimal separator for prices or PHP Locale settings.
* *
* @param string $value Decimal to localize. * @param string $value Decimal to localize.
* @return string * @return string
*/ */
function wc_format_localized_decimal( $value ) { function wc_format_localized_decimal( $value ) {
$locale = localeconv(); $locale = localeconv();
return apply_filters( 'woocommerce_format_localized_decimal', str_replace( '.', $locale['decimal_point'], strval( $value ) ), $value ); $decimal_point = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
$decimal = ( ! empty( wc_get_price_decimal_separator() ) ) ? wc_get_price_decimal_separator() : $decimal_point;
return apply_filters( 'woocommerce_format_localized_decimal', str_replace( '.', $decimal, strval( $value ) ), $value );
} }
/** /**