diff --git a/plugins/woocommerce/changelog/fix-48102-wcpay-incentive-promo-notes b/plugins/woocommerce/changelog/fix-48102-wcpay-incentive-promo-notes new file mode 100644 index 00000000000..6001d074084 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-48102-wcpay-incentive-promo-notes @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: We fix the WCPay incentives promo notes logic to avoid needless friction in the merchant UX. + + diff --git a/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php b/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php index 5c4c1f85d01..0815e1b4f8a 100644 --- a/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php +++ b/plugins/woocommerce/src/Internal/Admin/WcPayWelcomePage.php @@ -52,11 +52,13 @@ class WcPayWelcomePage { /** * Whether the WooPayments welcome page should be visible. * + * @param bool $skip_wcpay_active Whether to skip the check for the WooPayments plugin being active. + * * @return boolean */ - public function must_be_visible(): bool { + public function must_be_visible( $skip_wcpay_active = false ): bool { // The WooPayments plugin must not be active. - if ( $this->is_wcpay_active() ) { + if ( ! $skip_wcpay_active && $this->is_wcpay_active() ) { return false; } @@ -174,18 +176,20 @@ class WcPayWelcomePage { } /** - * Adds allowed promo notes from the WooPayments incentive. + * Adds allowed promo notes for the WooPayments incentives. * * @param array $promo_notes Allowed promo notes. * @return array */ public function allowed_promo_notes( $promo_notes = [] ): array { - // Return early if the incentive must not be visible. - if ( ! $this->must_be_visible() ) { + // Note: We need to disregard if WooPayments is active when adding the promo note to the list of + // allowed promo notes. The AJAX call that adds the promo note happens after WooPayments is installed and activated. + // Return early if the incentive page must not be visible, without checking if WooPayments is active. + if ( ! $this->must_be_visible( true ) ) { return $promo_notes; } - // Add our incentive ID to the promo notes. + // Add our incentive ID to the allowed promo notes so it can be added to the store. $promo_notes[] = $this->get_incentive()['id']; return $promo_notes;