Merge pull request #32746 from YordanSoares/use-price-decimal-separator-for-product-weight-and-dimensions

Use the price decimal separator to format product weight and dimensions
This commit is contained in:
Néstor Soriano 2022-05-02 12:04:26 +02:00 committed by GitHub
commit fbd38e5a90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Use the configured decimal separator to format product weight and dimensions

View File

@ -181,7 +181,8 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
wp_enqueue_script( 'jquery-ui-autocomplete' );
$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(
/* 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.
* @return string
*/
function wc_format_localized_decimal( $value ) {
$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 );
}
/**