Skip to content

Commit 2c59a00

Browse files
authored
Merge pull request #3523 from woocommerce/PCP-4998-fatal-error-when-using-feature-flag-filter-to-disable-new-settings-ui
Always enable the new settings module (4998)
2 parents 72dff6d + 4dd03c3 commit 2c59a00

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

modules.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
( require "$modules_dir/ppcp-blocks/module.php" )(),
3434
( require "$modules_dir/ppcp-paypal-subscriptions/module.php" )(),
3535
( require "$modules_dir/ppcp-local-alternative-payment-methods/module.php" )(),
36+
( require "$modules_dir/ppcp-settings/module.php" )(),
3637
);
3738
// phpcs:disable WordPress.NamingConventions.ValidHookName.UseUnderscores
3839

@@ -91,12 +92,5 @@
9192
$modules[] = ( require "$modules_dir/ppcp-axo-block/module.php" )();
9293
}
9394

94-
if ( apply_filters(
95-
'woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled',
96-
true
97-
) ) {
98-
$modules[] = ( require "$modules_dir/ppcp-settings/module.php" )();
99-
}
100-
10195
return $modules;
10296
};

modules/ppcp-settings/src/SettingsModule.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,29 @@ class SettingsModule implements ServiceModule, ExecutableModule {
6666
* Returns whether the old settings UI should be loaded.
6767
*/
6868
public static function should_use_the_old_ui() : bool {
69-
// New merchants should never see the #legacy-ui.
70-
$show_new_ux = '1' === get_option( 'woocommerce-ppcp-is-new-merchant' );
69+
/**
70+
* Determine if the new Settings UI is disabled via feature flag.
71+
*
72+
* This is the highest-priority check: if the `woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled` filter
73+
* is used to disable the new UI, it will override all other conditions.
74+
*/
75+
if ( ! apply_filters(
76+
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- feature flags use this convention
77+
'woocommerce.feature-flags.woocommerce_paypal_payments.settings_enabled',
78+
getenv( 'PCP_SETTINGS_ENABLED' ) !== '1'
79+
) ) {
80+
return true;
81+
}
7182

72-
if ( $show_new_ux ) {
83+
// New merchants always see the new UI if the filter above is not used.
84+
if ( '1' === get_option( 'woocommerce-ppcp-is-new-merchant' ) ) {
7385
return false;
7486
}
7587

76-
// Existing merchants can opt-in to see the new UI.
77-
$opt_out_choice = 'yes' === get_option( SwitchSettingsUiEndpoint::OPTION_NAME_SHOULD_USE_OLD_UI );
88+
// Existing merchants can opt out via DB option.
89+
$opt_out = 'yes' === get_option( SwitchSettingsUiEndpoint::OPTION_NAME_SHOULD_USE_OLD_UI );
7890

79-
return apply_filters(
80-
'woocommerce_paypal_payments_should_use_the_old_ui',
81-
$opt_out_choice
82-
);
91+
return apply_filters( 'woocommerce_paypal_payments_should_use_the_old_ui', $opt_out );
8392
}
8493

8594
/**

0 commit comments

Comments
 (0)