diff --git a/includes/admin/class-wc-rest-upe-flag-toggle-controller.php b/includes/admin/class-wc-rest-upe-flag-toggle-controller.php index 4234c87433c..37cd3958f26 100644 --- a/includes/admin/class-wc-rest-upe-flag-toggle-controller.php +++ b/includes/admin/class-wc-rest-upe-flag-toggle-controller.php @@ -117,12 +117,17 @@ private function update_is_upe_enabled( WP_REST_Request $request ) { $is_upe_enabled = $request->get_param( 'is_upe_enabled' ); if ( $is_upe_enabled ) { - update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' ); + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' ); return; } - // marking the flag as "disabled", so that we can keep track that the merchant explicitly disabled it. - update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' ); + // If the legacy UPE flag has been enabled, we need to disable the legacy UPE flag. + if ( '1' === get_option( WC_Payments_Features::UPE_FLAG_NAME ) ) { + update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' ); + } else { + // marking the flag as "disabled", so that we can keep track that the merchant explicitly disabled it. + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'disabled' ); + } // resetting a few other things: // removing the UPE payment methods and _only_ leaving "card", diff --git a/includes/class-wc-payments-account.php b/includes/class-wc-payments-account.php index 177a7ea958f..f64ea0f850a 100644 --- a/includes/class-wc-payments-account.php +++ b/includes/class-wc-payments-account.php @@ -1073,6 +1073,9 @@ private function finalize_connection( $state, $mode ) { // user might not have agreed to TOS yet. update_option( '_wcpay_onboarding_stripe_connected', [ 'is_existing_stripe_account' => false ] ); + // Automatically enable split UPE for new stores. + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' ); + wp_safe_redirect( add_query_arg( [ diff --git a/includes/migrations/class-track-upe-status.php b/includes/migrations/class-track-upe-status.php index 2cf41be2263..4456ae98841 100644 --- a/includes/migrations/class-track-upe-status.php +++ b/includes/migrations/class-track-upe-status.php @@ -31,7 +31,7 @@ public static function maybe_track() { return; } - $upe_value = get_option( \WC_Payments_Features::UPE_FLAG_NAME, 'not-set' ); + $upe_value = get_option( \WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'not-set' ); // Don't trigger the track event when the flag isn't set. if ( 'not-set' !== $upe_value ) { diff --git a/includes/notes/class-wc-payments-notes-additional-payment-methods.php b/includes/notes/class-wc-payments-notes-additional-payment-methods.php index a1d09787081..fe093959e27 100644 --- a/includes/notes/class-wc-payments-notes-additional-payment-methods.php +++ b/includes/notes/class-wc-payments-notes-additional-payment-methods.php @@ -120,7 +120,7 @@ public static function maybe_enable_upe_feature_flag() { } // Enable UPE, deletes the note and redirect to onboarding task. - update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' ); + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' ); self::possibly_delete_note(); $wcpay_settings_url = admin_url( 'admin.php?page=wc-admin&path=/payments/additional-payment-methods' ); diff --git a/tests/unit/migrations/test-class-track-upe-status.php b/tests/unit/migrations/test-class-track-upe-status.php index 4c59006f3af..85ed544354d 100644 --- a/tests/unit/migrations/test-class-track-upe-status.php +++ b/tests/unit/migrations/test-class-track-upe-status.php @@ -23,6 +23,8 @@ public function set_up() { parent::set_up(); delete_option( Track_Upe_Status::IS_TRACKED_OPTION ); + delete_option( WC_Payments_Features::UPE_FLAG_NAME ); + delete_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME ); } /** @@ -39,7 +41,7 @@ public function tear_down() { * Make sure the 'wcpay_upe_enabled' event is registered when upe is enabled. */ public function test_track_enabled_on_upgrade() { - update_option( WC_Payments_Features::UPE_FLAG_NAME, '1' ); + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, '1' ); Track_Upe_Status::maybe_track(); @@ -54,7 +56,7 @@ public function test_track_enabled_on_upgrade() { } public function test_track_disabled_on_upgrade() { - update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' ); + update_option( WC_Payments_Features::UPE_SPLIT_FLAG_NAME, 'disabled' ); Track_Upe_Status::maybe_track();