* Currency: re-add deprecated formatCurrency

* better warning

* bump removal version to 5.0.0
This commit is contained in:
Paul Sealock 2020-07-31 07:32:09 +12:00 committed by GitHub
parent adf51fc173
commit c621bade17
3 changed files with 24 additions and 2 deletions

View File

@ -7758,7 +7758,8 @@
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/runtime-corejs2": "7.10.5", "@babel/runtime-corejs2": "7.10.5",
"@woocommerce/number": "2.0.0" "@woocommerce/number": "2.0.0",
"@wordpress/deprecated": "^2.9.0"
} }
}, },
"@woocommerce/data": { "@woocommerce/data": {

View File

@ -22,7 +22,8 @@
"react-native": "src/index", "react-native": "src/index",
"dependencies": { "dependencies": {
"@babel/runtime-corejs2": "7.10.5", "@babel/runtime-corejs2": "7.10.5",
"@woocommerce/number": "2.0.0" "@woocommerce/number": "2.0.0",
"@wordpress/deprecated": "^2.9.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"

View File

@ -3,6 +3,7 @@
*/ */
import { sprintf } from '@wordpress/i18n'; import { sprintf } from '@wordpress/i18n';
import { numberFormat } from '@woocommerce/number'; import { numberFormat } from '@woocommerce/number';
import deprecated from '@wordpress/deprecated';
const CurrencyFactory = ( currencySetting ) => { const CurrencyFactory = ( currencySetting ) => {
let currency; let currency;
@ -48,6 +49,24 @@ const CurrencyFactory = ( currencySetting ) => {
return sprintf( priceFormat, symbol, formattedNumber ); 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. * Get the default price format from a currency.
* *
@ -79,6 +98,7 @@ const CurrencyFactory = ( currencySetting ) => {
}, },
setCurrency, setCurrency,
formatAmount, formatAmount,
formatCurrency,
getPriceFormat, getPriceFormat,
/** /**