Skip to content

Commit

Permalink
Minor updates to Tracks onboarding events props (#9015)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladolaru authored Jun 26, 2024
1 parent 471bcba commit 56b35cf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changelog/update-tracks-onboarding-events-props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: update
Comment: These changes are only related to Tracks events props updates.


1 change: 1 addition & 0 deletions client/connect-account-page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const ConnectAccountPage: React.FC = () => {
incentive_id: incentive.id,
} ),
sandbox_mode: sandboxMode,
path: 'payments_connect_v2',
} );
};

Expand Down
4 changes: 4 additions & 0 deletions includes/class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ public function maybe_redirect_to_wcpay_connect(): bool {
[
'wcpay-connect' => '1',
'_wpnonce' => wp_create_nonce( 'wcpay-connect' ),
'from' => 'WCPAY_KYC_REMINDER',
],
admin_url( 'admin.php' )
);
Expand Down Expand Up @@ -871,6 +872,7 @@ public function maybe_redirect_settings_to_connect_or_overview(): bool {
[
'page' => 'wc-admin',
'path' => '/payments/connect',
'from' => 'WCADMIN_PAYMENT_SETTINGS',
],
'admin.php'
)
Expand All @@ -890,6 +892,7 @@ public function maybe_redirect_settings_to_connect_or_overview(): bool {
[
'page' => 'wc-admin',
'path' => '/payments/overview',
'from' => 'WCADMIN_PAYMENT_SETTINGS',
],
'admin.php'
)
Expand Down Expand Up @@ -942,6 +945,7 @@ public function maybe_redirect_onboarding_flow_to_overview(): bool {
[
'page' => 'wc-admin',
'path' => '/payments/overview',
'from' => 'WCPAY_ONBOARDING_FLOW',
],
'admin.php'
)
Expand Down
9 changes: 7 additions & 2 deletions includes/class-wc-payments-onboarding-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,12 @@ public static function is_test_mode_enabled(): bool {
* @return string The source or empty string if the source is unsupported.
*/
public static function get_source( string $referer, array $get_params ): string {
$wcpay_connect_param = sanitize_text_field( wp_unslash( $get_params['wcpay-connect'] ) );
if ( 'WCADMIN_PAYMENT_TASK' === $wcpay_connect_param ) {
$wcpay_connect_param = isset( $get_params['wcpay-connect'] ) ? sanitize_text_field( wp_unslash( $get_params['wcpay-connect'] ) ) : '';
$from_param = isset( $get_params['from'] ) ? sanitize_text_field( wp_unslash( $get_params['from'] ) ) : '';

// Sometimes we have it in the `wcpay-connect` param and other times in the `from` one.
if ( 'WCADMIN_PAYMENT_TASK' === $wcpay_connect_param
|| 'WCADMIN_PAYMENT_TASK' === $from_param ) {
return self::SOURCE_WCADMIN_PAYMENT_TASK;
}
// Payments tab in Woo Admin Settings page.
Expand All @@ -266,6 +270,7 @@ public static function get_source( string $referer, array $get_params ): string
if ( isset( $get_params['wcpay-reset-account'] ) ) {
return self::SOURCE_WCPAY_RESET_ACCOUNT;
}

return '';
}
}
4 changes: 2 additions & 2 deletions tests/unit/test-class-wc-payments-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public function data_maybe_redirect_settings_to_connect_or_overview() {
'section' => 'woocommerce_payments',
],
true,
'connect',
'connect&from=WCADMIN_PAYMENT_SETTINGS',
],
'account_partially_onboarded' => [
1,
Expand All @@ -597,7 +597,7 @@ public function data_maybe_redirect_settings_to_connect_or_overview() {
'section' => 'woocommerce_payments',
],
false,
'overview',
'overview&from=WCADMIN_PAYMENT_SETTINGS',
],
'account_fully_onboarded' => [
0,
Expand Down

0 comments on commit 56b35cf

Please sign in to comment.