mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
♻️ Replace generatePriceText with custom component
This commit is contained in:
parent
a3b68aae14
commit
e59ae23c43
8 changed files with 159 additions and 125 deletions
|
@ -0,0 +1,29 @@
|
|||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { countryPriceInfo } from '../../utils/countryPriceInfo';
|
||||
import TitleBadge, { TITLE_BADGE_INFO } from './TitleBadge';
|
||||
import { CommonHooks } from '../../data';
|
||||
|
||||
const PricingTitleBadge = ( { item, country, currency } ) => {
|
||||
const infos = countryPriceInfo[ country ];
|
||||
|
||||
if ( ! infos || ! infos[ item ] ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const percentage = infos[ item ].toFixed( 2 );
|
||||
const fixedFee = `${ infos.currencySymbol }${ infos.fixedFee }`;
|
||||
|
||||
const label = sprintf(
|
||||
__(
|
||||
'from %1$s%% + %2$s %2$s<sup>1</sup>',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
percentage,
|
||||
fixedFee,
|
||||
currency
|
||||
);
|
||||
|
||||
return <TitleBadge type={ TITLE_BADGE_INFO } text={ label } />;
|
||||
};
|
||||
|
||||
export default PricingTitleBadge;
|
Loading…
Add table
Add a link
Reference in a new issue