mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-04-27 01:22:18 +08:00
Some checks failed
CI / PHP 7.4 (push) Has been cancelled
CI / PHP 8.0 (push) Has been cancelled
CI / PHP 8.1 (push) Has been cancelled
CI / PHP 8.2 (push) Has been cancelled
CI / PHP 8.3 (push) Has been cancelled
CI / PHP 8.4 (push) Has been cancelled
PR Playground Demo / prepare_version (push) Has been cancelled
PR Playground Demo / build_plugin (push) Has been cancelled
PR Playground Demo / create_archive (push) Has been cancelled
PR Playground Demo / Comment on PR with Playground details (push) Has been cancelled
34 lines
568 B
JavaScript
34 lines
568 B
JavaScript
const priceFormatInfo = {
|
|
USD: {
|
|
prefix: '$',
|
|
suffix: ' USD',
|
|
},
|
|
CAD: {
|
|
prefix: '$',
|
|
suffix: ' CAD',
|
|
},
|
|
AUD: {
|
|
prefix: '$',
|
|
suffix: ' AUD',
|
|
},
|
|
EUR: {
|
|
prefix: '€',
|
|
suffix: '',
|
|
},
|
|
GBP: {
|
|
prefix: '£',
|
|
suffix: '',
|
|
},
|
|
};
|
|
|
|
export const formatPrice = ( value, currency ) => {
|
|
const currencyInfo = priceFormatInfo[ currency ];
|
|
const amount = value.toFixed( 2 );
|
|
|
|
if ( ! currencyInfo ) {
|
|
console.error( `Unsupported currency: ${ currency }` );
|
|
return amount;
|
|
}
|
|
|
|
return `${ currencyInfo.prefix }${ amount }${ currencyInfo.suffix }`;
|
|
};
|