From da7ba25f31eca94359d93779ca442a39dad0a291 Mon Sep 17 00:00:00 2001 From: Oleksandr Aratovskyi <79862886+oaratovskyi@users.noreply.github.com> Date: Wed, 8 Nov 2023 19:58:40 +0200 Subject: [PATCH] Polish logic of redirect when click Set Up WooPayments from WC Home (#7659) Co-authored-by: Vlad Olaru --- ...yments-link-from-core-polish-current-logic | 5 ++++ includes/class-wc-payments-account.php | 24 ++++--------------- 2 files changed, 10 insertions(+), 19 deletions(-) create mode 100644 changelog/tweak-7625-set-up-woopayments-link-from-core-polish-current-logic diff --git a/changelog/tweak-7625-set-up-woopayments-link-from-core-polish-current-logic b/changelog/tweak-7625-set-up-woopayments-link-from-core-polish-current-logic new file mode 100644 index 00000000000..f326a0a97d7 --- /dev/null +++ b/changelog/tweak-7625-set-up-woopayments-link-from-core-polish-current-logic @@ -0,0 +1,5 @@ +Significance: patch +Type: fix +Comment: Addition to 7625 - polish logic of redirect when click Set Up WooPayments from WC Home + + diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index e39253ee6e7..69e7108b47c 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -222,21 +222,6 @@ public function is_account_rejected(): bool { return strpos( $account['status'] ?? '', 'rejected' ) === 0; } - /** - * Checks if the account has been completed. - * Returns false if the account is not connected. - * - * @return bool True if the account is connected and complete, false otherwise or on error. - */ - public function is_account_complete(): bool { - if ( ! $this->is_stripe_connected() ) { - return false; - } - - $account = $this->get_cached_account_data(); - return 'complete' === $account['status']; - } - /** * Checks if the account has not completed onboarding due to users abandoning the process half way. * Returns true if the onboarding is started but did not finish. @@ -949,11 +934,12 @@ public function maybe_handle_onboarding() { $from_wc_admin_task = 'WCADMIN_PAYMENT_TASK' === $wcpay_connect_param; $from_wc_pay_connect_page = false !== strpos( wp_get_referer(), 'path=%2Fpayments%2Fconnect' ); if ( ( $from_wc_admin_task || $from_wc_pay_connect_page ) ) { - // Redirect complete accounts to payments overview page, otherwise to the onboarding flow. - if ( $this->is_account_complete() ) { - $this->redirect_to( static::get_overview_page_url() ); - } else { + // Redirect non-onboarded account to the onboarding flow, otherwise to payments overview page. + if ( ! $this->is_stripe_connected() ) { $this->redirect_to_onboarding_flow_page(); + } else { + // Accounts with Stripe account connected will be redirected to the overview page. + $this->redirect_to( static::get_overview_page_url() ); } }