Merge pull request #2943 from woocommerce/fix/PCP-4034-update-pricing-badges

This commit is contained in:
Narek Zakarian 2024-12-24 11:38:46 +04:00 committed by GitHub
commit c85cd98347
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 79 additions and 15 deletions

View file

@ -5,26 +5,29 @@ import { countryPriceInfo } from '../../utils/countryPriceInfo';
import { formatPrice } from '../../utils/formatPrice'; import { formatPrice } from '../../utils/formatPrice';
import TitleBadge, { TITLE_BADGE_INFO } from './TitleBadge'; import TitleBadge, { TITLE_BADGE_INFO } from './TitleBadge';
const getFixedAmount = ( currency, priceList ) => { const getFixedAmount = ( currency, priceList, itemFixedAmount ) => {
if ( priceList[ currency ] ) { if ( priceList[ currency ] ) {
return formatPrice( priceList[ currency ], currency ); const sum = priceList[ currency ] + itemFixedAmount;
return formatPrice( sum, currency );
} }
const [ defaultCurrency, defaultPrice ] = Object.entries( priceList )[ 0 ]; const [ defaultCurrency, defaultPrice ] = Object.entries( priceList )[ 0 ];
const sum = defaultPrice + itemFixedAmount;
return formatPrice( defaultPrice, defaultCurrency ); return formatPrice( sum, defaultCurrency );
}; };
const PricingTitleBadge = ( { item } ) => { const PricingTitleBadge = ( { item } ) => {
const { storeCountry } = CommonHooks.useWooSettings(); const { storeCountry, storeCurrency } = CommonHooks.useWooSettings();
const infos = countryPriceInfo[ storeCountry ]; const infos = countryPriceInfo[ storeCountry ];
const itemKey = item.split(' ')[0]; // Extract the first word, fastlane has more than one
if ( ! infos || ! infos[ item ] ) { if ( ! infos || ! infos[ itemKey ] ) {
return null; return null;
} }
const percentage = infos[ item ].toFixed( 2 ); const percentage = typeof infos[itemKey] === 'number' ? infos[itemKey].toFixed(2) : infos[itemKey]['percentage'].toFixed(2);
const fixedAmount = getFixedAmount( storeCountry, infos.fixedFee ); const itemFixedAmount = infos[itemKey]['fixedFee'] ? infos[itemKey]['fixedFee'] : 0;
const fixedAmount = getFixedAmount( storeCurrency, infos.fixedFee, itemFixedAmount );
const label = sprintf( const label = sprintf(
__( 'from %1$s%% + %2$s', 'woocommerce-paypal-payments' ), __( 'from %1$s%% + %2$s', 'woocommerce-paypal-payments' ),

View file

@ -53,6 +53,9 @@ const AcdcFlow = ( { isFastlane, isPayLater, storeCountry } ) => {
imageBadge={ [ imageBadge={ [
'icon-payment-method-paypal-small.svg', 'icon-payment-method-paypal-small.svg',
] } ] }
textBadge={
<PricingTitleBadge item="plater" />
}
description={ sprintf( description={ sprintf(
// translators: %s: Link to PayPal business fees guide // translators: %s: Link to PayPal business fees guide
__( __(

View file

@ -2,81 +2,139 @@ export const countryPriceInfo = {
US: { US: {
fixedFee: { fixedFee: {
USD: 0.49, USD: 0.49,
GBP: 0.39,
CAD: 0.59,
AUD: 0.59,
EUR: 0.39,
}, },
checkout: 3.49, checkout: 3.49,
ccf: 2.59, plater: 4.99,
dw: 2.59, ccf: {
apm: 2.59, percentage: 2.59,
fastlane: 2.59, fixedFee: 0.29,
},
dw: {
percentage: 2.59,
fixedFee: 0.29,
},
apm: {
percentage: 2.89,
fixedFee: 0.29,
},
fast: {
percentage: 2.59,
fixedFee: 0.29,
},
standardCardFields: 2.99, standardCardFields: 2.99,
}, },
UK: { UK: {
fixedFee: { fixedFee: {
GPB: 0.3, GPB: 0.3,
USD: 0.3,
CAD: 0.3,
AUD: 0.3,
EUR: 0.35,
}, },
checkout: 2.9, checkout: 2.9,
plater: 2.9,
ccf: 1.2, ccf: 1.2,
dw: 1.2, dw: 1.2,
fast: 1.2,
apm: 1.2, apm: 1.2,
standardCardFields: 1.2, standardCardFields: 1.2,
}, },
CA: { CA: {
fixedFee: { fixedFee: {
CAD: 0.3, CAD: 0.3,
USD: 0.3,
GBP: 0.2,
AUD: 0.3,
EUR: 0.35,
}, },
checkout: 2.9, checkout: 2.9,
ccf: 2.7, ccf: 2.7,
dw: 2.7, dw: 2.7,
fast: 2.7,
apm: 2.9, apm: 2.9,
standardCardFields: 2.9, standardCardFields: 2.9,
}, },
AU: { AU: {
fixedFee: { fixedFee: {
AUD: 0.3, AUD: 0.3,
USD: 0.3,
GBP: 0.2,
CAD: 0.3,
EUR: 0.35,
}, },
checkout: 2.6, checkout: 2.6,
plater: 2.6,
ccf: 1.75, ccf: 1.75,
dw: 1.75, dw: 1.75,
fast: 1.75,
apm: 2.6, apm: 2.6,
standardCardFields: 2.6, standardCardFields: 2.6,
}, },
FR: { FR: {
fixedFee: { fixedFee: {
EUR: 0.35, EUR: 0.35,
USD: 0.3,
GBP: 0.3,
CAD: 0.3,
AUD: 0.3,
}, },
checkout: 2.9, checkout: 2.9,
plater: 2.9,
ccf: 1.2, ccf: 1.2,
dw: 1.2, dw: 1.2,
fast: 1.2,
apm: 1.2, apm: 1.2,
standardCardFields: 1.2, standardCardFields: 1.2,
}, },
IT: { IT: {
fixedFee: { fixedFee: {
EUR: 0.35, EUR: 0.35,
USD: 0.3,
GBP: 0.3,
CAD: 0.3,
AUD: 0.3,
}, },
checkout: 3.4, checkout: 3.4,
plater: 3.4,
ccf: 1.2, ccf: 1.2,
dw: 1.2, dw: 1.2,
fast: 1.2,
apm: 1.2, apm: 1.2,
standardCardFields: 1.2, standardCardFields: 1.2,
}, },
DE: { DE: {
fixedFee: { fixedFee: {
EUR: 0.39, EUR: 0.39,
USD: 0.49,
GBP: 0.29,
CAD: 0.59,
AUD: 0.59,
}, },
checkout: 2.99, checkout: 2.99,
plater: 2.99,
ccf: 2.99, ccf: 2.99,
dw: 2.99, dw: 2.99,
fast: 2.99,
apm: 2.99, apm: 2.99,
standardCardFields: 2.99, standardCardFields: 2.99,
}, },
ES: { ES: {
fixedFee: { fixedFee: {
EUR: 0.35, EUR: 0.35,
USD: 0.3,
GBP: 0.3,
CAD: 0.3,
AUD: 0.3,
}, },
checkout: 2.9, checkout: 2.9,
plater: 2.9,
ccf: 1.2, ccf: 1.2,
dw: 1.2, dw: 1.2,
fast: 1.2,
apm: 1.2, apm: 1.2,
standardCardFields: 1.2, standardCardFields: 1.2,
}, },