Currency: re-add deprecated formatCurrency (https://github.com/woocommerce/woocommerce-admin/pull/4891)
* Currency: re-add deprecated formatCurrency * better warning * bump removal version to 5.0.0
This commit is contained in:
parent
adf51fc173
commit
c621bade17
|
@ -7758,7 +7758,8 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/runtime-corejs2": "7.10.5",
|
||||
"@woocommerce/number": "2.0.0"
|
||||
"@woocommerce/number": "2.0.0",
|
||||
"@wordpress/deprecated": "^2.9.0"
|
||||
}
|
||||
},
|
||||
"@woocommerce/data": {
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
"react-native": "src/index",
|
||||
"dependencies": {
|
||||
"@babel/runtime-corejs2": "7.10.5",
|
||||
"@woocommerce/number": "2.0.0"
|
||||
"@woocommerce/number": "2.0.0",
|
||||
"@wordpress/deprecated": "^2.9.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
import { sprintf } from '@wordpress/i18n';
|
||||
import { numberFormat } from '@woocommerce/number';
|
||||
import deprecated from '@wordpress/deprecated';
|
||||
|
||||
const CurrencyFactory = ( currencySetting ) => {
|
||||
let currency;
|
||||
|
@ -48,6 +49,24 @@ const CurrencyFactory = ( currencySetting ) => {
|
|||
return sprintf( priceFormat, symbol, formattedNumber );
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats money value.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @param {number|string} number number to format
|
||||
* @return {?string} A formatted string.
|
||||
*/
|
||||
function formatCurrency( number ) {
|
||||
deprecated( 'Currency().formatCurrency', {
|
||||
version: '5.0.0',
|
||||
alternative: 'Currency().formatAmount',
|
||||
plugin: 'WooCommerce',
|
||||
hint: '`formatAmount` accepts the same arguments as formatCurrency',
|
||||
} );
|
||||
return formatAmount( number );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default price format from a currency.
|
||||
*
|
||||
|
@ -79,6 +98,7 @@ const CurrencyFactory = ( currencySetting ) => {
|
|||
},
|
||||
setCurrency,
|
||||
formatAmount,
|
||||
formatCurrency,
|
||||
getPriceFormat,
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue