woocommerce-paypal-payments/modules/ppcp-settings/resources/js/utils/badgeBoxUtils.js

19 lines
583 B
JavaScript
Raw Normal View History

import { __ } from '@wordpress/i18n';
2024-11-26 15:01:21 +04:00
const generatePriceText = ( type, selectedCountryPrice, storeCurrency ) => {
if ( ! selectedCountryPrice || ! selectedCountryPrice[ type ] ) {
console.warn( `Invalid type or price data for: ${ type }` );
return '';
}
2024-11-26 15:01:21 +04:00
const percentage = selectedCountryPrice[ type ].toFixed( 2 );
const fixedFee = `${ selectedCountryPrice.currencySymbol }${ selectedCountryPrice.fixedFee }`;
2024-11-26 15:01:21 +04:00
return __(
`from ${ percentage }% + ${ fixedFee } ${ storeCurrency }<sup>1</sup>`,
'woocommerce-paypal-payments'
);
};
export default generatePriceText;