diff --git a/changelog/fix-3693-qualitative-feedback-note b/changelog/fix-3693-qualitative-feedback-note
new file mode 100644
index 00000000000..8862cc0c961
--- /dev/null
+++ b/changelog/fix-3693-qualitative-feedback-note
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Update Qualitative Feedback note to have more efficient sql query.
diff --git a/changelog/fix-7750-include-discount-in-tooltip b/changelog/fix-7750-include-discount-in-tooltip
new file mode 100644
index 00000000000..b600a611e92
--- /dev/null
+++ b/changelog/fix-7750-include-discount-in-tooltip
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Include discount fee in fees tooltip
diff --git a/changelog/fix-account-currency-hook b/changelog/fix-account-currency-hook
new file mode 100644
index 00000000000..23d9628b19f
--- /dev/null
+++ b/changelog/fix-account-currency-hook
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+fix: account currency hook return value
diff --git a/client/payment-methods/index.js b/client/payment-methods/index.js
index 950610e6fba..7efb306b0da 100644
--- a/client/payment-methods/index.js
+++ b/client/payment-methods/index.js
@@ -92,7 +92,7 @@ const PaymentMethods = () => {
const [ , updateSelectedPaymentMethod ] = useSelectedPaymentMethod();
- const [ stripeAccountDomesticCurrency ] = useAccountDomesticCurrency();
+ const stripeAccountDomesticCurrency = useAccountDomesticCurrency();
const completeActivation = ( itemId ) => {
updateSelectedPaymentMethod( itemId );
diff --git a/client/utils/account-fees.tsx b/client/utils/account-fees.tsx
index 6ba2674de6d..c2b3214c1b5 100644
--- a/client/utils/account-fees.tsx
+++ b/client/utils/account-fees.tsx
@@ -74,24 +74,31 @@ const getStripeFeeSectionUrl = ( country: string ): string => {
);
};
-const getFeeDescriptionString = ( fee: BaseFee ): string => {
+const getFeeDescriptionString = (
+ fee: BaseFee,
+ discountBasedMultiplier: number
+): string => {
if ( fee.fixed_rate && fee.percentage_rate ) {
return sprintf(
'%1$f%% + %2$s',
- formatFee( fee.percentage_rate ),
- formatCurrency( fee.fixed_rate, fee.currency )
+ formatFee( fee.percentage_rate * discountBasedMultiplier ),
+ formatCurrency(
+ fee.fixed_rate * discountBasedMultiplier,
+ fee.currency
+ )
);
} else if ( fee.fixed_rate ) {
return sprintf(
- '%2$s',
- formatFee( fee.percentage_rate ),
- formatCurrency( fee.fixed_rate, fee.currency )
+ '%1$s',
+ formatCurrency(
+ fee.fixed_rate * discountBasedMultiplier,
+ fee.currency
+ )
);
} else if ( fee.percentage_rate ) {
return sprintf(
'%1$f%%',
- formatFee( fee.percentage_rate ),
- formatCurrency( fee.fixed_rate, fee.currency )
+ formatFee( fee.percentage_rate * discountBasedMultiplier )
);
}
return '';
@@ -109,19 +116,19 @@ export const formatMethodFeesTooltip = (
accountFees: FeeStructure
): JSX.Element => {
if ( ! accountFees ) return <>>;
- const currentBaseFee = getCurrentBaseFee( accountFees );
- // If the current fee doesn't have a fixed or percentage rate, use the base fee's rate. Eg. when there is a promotional discount fee applied. Use this to calculate the total fee too.
- const currentFeeWithBaseFallBack = currentBaseFee.percentage_rate
- ? currentBaseFee
- : accountFees.base;
+
+ const discountAdjustedFeeRate: number =
+ accountFees.discount.length && accountFees.discount[ 0 ].discount
+ ? 1 - accountFees.discount[ 0 ].discount
+ : 1;
const total = {
percentage_rate:
- currentFeeWithBaseFallBack.percentage_rate +
+ accountFees.base.percentage_rate +
accountFees.additional.percentage_rate +
accountFees.fx.percentage_rate,
fixed_rate:
- currentFeeWithBaseFallBack.fixed_rate +
+ accountFees.base.fixed_rate +
accountFees.additional.fixed_rate +
accountFees.fx.fixed_rate,
currency: accountFees.base.currency,
@@ -136,14 +143,20 @@ export const formatMethodFeesTooltip = (
Base fee
- { getFeeDescriptionString( currentFeeWithBaseFallBack ) }
+ { getFeeDescriptionString(
+ accountFees.base,
+ discountAdjustedFeeRate
+ ) }
{ hasFees( accountFees.additional ) ? (
International payment method fee
- { getFeeDescriptionString( accountFees.additional ) }
+ { getFeeDescriptionString(
+ accountFees.additional,
+ discountAdjustedFeeRate
+ ) }
) : (
@@ -152,7 +165,12 @@ export const formatMethodFeesTooltip = (
{ hasFees( accountFees.fx ) ? (
Foreign exchange fee
-
{ getFeeDescriptionString( accountFees.fx ) }
+
+ { getFeeDescriptionString(
+ accountFees.fx,
+ discountAdjustedFeeRate
+ ) }
+
) : (
''
@@ -160,7 +178,10 @@ export const formatMethodFeesTooltip = (
Total per transaction
- { getFeeDescriptionString( total ) }
+ { getFeeDescriptionString(
+ total,
+ discountAdjustedFeeRate
+ ) }
{ wcpaySettings &&
diff --git a/client/utils/test/__snapshots__/account-fees.tsx.snap b/client/utils/test/__snapshots__/account-fees.tsx.snap
index 5ec2897e12b..5388a2b344d 100644
--- a/client/utils/test/__snapshots__/account-fees.tsx.snap
+++ b/client/utils/test/__snapshots__/account-fees.tsx.snap
@@ -10,7 +10,7 @@ exports[`Account fees utility functions formatMethodFeesTooltip() displays base
Base fee
- 12.3% + $4.57
+ 9.84% + $3.65
@@ -18,7 +18,7 @@ exports[`Account fees utility functions formatMethodFeesTooltip() displays base
International payment method fee
- 1%
+ 0.8%
@@ -26,7 +26,7 @@ exports[`Account fees utility functions formatMethodFeesTooltip() displays base
Foreign exchange fee
- 1%
+ 0.8%
@@ -36,7 +36,7 @@ exports[`Account fees utility functions formatMethodFeesTooltip() displays base
- 14.3% + $4.57
+ 11.44% + $3.65
`;
-
-exports[`Account fees utility functions formatMethodFeesTooltip() displays custom fee details, when applicable 1`] = `
-
-`;
diff --git a/client/utils/test/account-fees.tsx b/client/utils/test/account-fees.tsx
index 72cf891067b..c1b181ac160 100644
--- a/client/utils/test/account-fees.tsx
+++ b/client/utils/test/account-fees.tsx
@@ -310,35 +310,6 @@ describe( 'Account fees utility functions', () => {
expect( container ).toMatchSnapshot();
} );
- it( 'displays custom fee details, when applicable', () => {
- const methodFees = mockAccountFees(
- {
- percentage_rate: 0.123,
- fixed_rate: 456.78,
- currency: 'USD',
- },
- [ { percentage_rate: 0.101, fixed_rate: 400.78 } ]
- );
-
- methodFees.additional = {
- percentage_rate: 0.01,
- fixed_rate: 0,
- currency: 'USD',
- };
-
- methodFees.fx = {
- percentage_rate: 0.01,
- fixed_rate: 0,
- currency: 'USD',
- };
-
- const { container } = render(
- formatMethodFeesTooltip( methodFees )
- );
-
- expect( container ).toMatchSnapshot();
- } );
-
it( 'displays base fee, when only promo discount without percentage or fixed', () => {
const methodFees = mockAccountFees(
{
diff --git a/includes/notes/class-wc-payments-notes-qualitative-feedback.php b/includes/notes/class-wc-payments-notes-qualitative-feedback.php
index 266e1dd70f1..031fbd6b473 100644
--- a/includes/notes/class-wc-payments-notes-qualitative-feedback.php
+++ b/includes/notes/class-wc-payments-notes-qualitative-feedback.php
@@ -38,8 +38,27 @@ public static function get_note() {
}
// We should have at least one transaction.
- $token_count = $wpdb->get_var( "select count(*) from {$wpdb->prefix}woocommerce_payment_tokens" );
- if ( 0 === (int) $token_count ) {
+ if ( WC_Payments_Utils::is_hpos_tables_usage_enabled() ) {
+ $result = $wpdb->get_var(
+ "SELECT EXISTS(
+ SELECT 1
+ FROM {$wpdb->prefix}wc_orders_meta
+ WHERE meta_key = '_wcpay_transaction_fee'
+ LIMIT 1)
+ AS count;"
+ );
+ } else {
+ $result = $wpdb->get_var(
+ "SELECT EXISTS(
+ SELECT 1
+ FROM {$wpdb->postmeta}
+ WHERE meta_key = '_wcpay_transaction_fee'
+ LIMIT 1)
+ AS count;"
+ );
+ }
+
+ if ( 1 !== intval( $result ) ) {
return;
}