diff --git a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php index 61668c26d..c7ff102fe 100644 --- a/modules/ppcp-applepay/src/Assets/AppleProductStatus.php +++ b/modules/ppcp-applepay/src/Assets/AppleProductStatus.php @@ -89,6 +89,7 @@ class AppleProductStatus extends ProductStatus { } } + // Settings used as a cache; `settings->set` is compatible with new UI. if ( $has_capability ) { $this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED ); } else { diff --git a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php index 775be302e..2e8cc4c0b 100644 --- a/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php +++ b/modules/ppcp-button/src/Endpoint/ApproveOrderEndpoint.php @@ -272,8 +272,9 @@ class ApproveOrderEndpoint implements EndpointInterface { * @return void */ protected function toggle_final_review_enabled_setting(): void { + // TODO new-ux: This flag must also be updated in the new settings. $final_review_enabled_setting = $this->settings->has( 'blocks_final_review_enabled' ) && $this->settings->get( 'blocks_final_review_enabled' ); - $final_review_enabled_setting ? $this->settings->set( 'blocks_final_review_enabled', false ) : $this->settings->set( 'blocks_final_review_enabled', true ); + $this->settings->set( 'blocks_final_review_enabled', ! $final_review_enabled_setting ); $this->settings->persist(); } } diff --git a/modules/ppcp-googlepay/src/Helper/ApmProductStatus.php b/modules/ppcp-googlepay/src/Helper/ApmProductStatus.php index dbe812837..20917eac7 100644 --- a/modules/ppcp-googlepay/src/Helper/ApmProductStatus.php +++ b/modules/ppcp-googlepay/src/Helper/ApmProductStatus.php @@ -89,6 +89,7 @@ class ApmProductStatus extends ProductStatus { } } + // Settings used as a cache; `settings->set` is compatible with new UI. if ( $has_capability ) { $this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED ); } else { diff --git a/modules/ppcp-local-alternative-payment-methods/src/LocalApmProductStatus.php b/modules/ppcp-local-alternative-payment-methods/src/LocalApmProductStatus.php index 2a89146be..546a94d15 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/LocalApmProductStatus.php +++ b/modules/ppcp-local-alternative-payment-methods/src/LocalApmProductStatus.php @@ -71,6 +71,7 @@ class LocalApmProductStatus extends ProductStatus { } } + // Settings used as a cache; `settings->set` is compatible with new UI. if ( $has_capability ) { $this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED ); } else { diff --git a/modules/ppcp-paylater-configurator/src/Endpoint/SaveConfig.php b/modules/ppcp-paylater-configurator/src/Endpoint/SaveConfig.php index b1f77de85..6c1dc4b41 100644 --- a/modules/ppcp-paylater-configurator/src/Endpoint/SaveConfig.php +++ b/modules/ppcp-paylater-configurator/src/Endpoint/SaveConfig.php @@ -95,6 +95,7 @@ class SaveConfig { * @param array $config The configurator config. */ public function save_config( array $config ): void { + // TODO new-ux: We should convert this to a new AbstractDataModel class in the settings folder! $this->settings->set( 'pay_later_enable_styling_per_messaging_location', true ); $this->settings->set( 'pay_later_messaging_enabled', true ); diff --git a/modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php b/modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php index f67c7c6f1..1bb186a25 100644 --- a/modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php +++ b/modules/ppcp-wc-gateway/src/Cli/SettingsCommand.php @@ -62,6 +62,7 @@ class SettingsCommand { $value = false; } + // TODO new-ux: The setting must also be updated in the new settings. $this->settings->set( $key, $value ); $this->settings->persist(); diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 7ed9532e8..10ec5ab2c 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -137,6 +137,10 @@ class PayUponInvoice { */ public function init(): void { if ( $this->pui_helper->is_pui_gateway_enabled() ) { + /* + * TODO new-ux: Check if we still support this setting, or if it's always enabled. + * If fraudnet is not configurable in new UI, we can ignore this. + */ $this->settings->set( 'fraudnet_enabled', true ); $this->settings->persist(); } diff --git a/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php b/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php index d82271b60..980b4d2d0 100644 --- a/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php +++ b/modules/ppcp-wc-gateway/src/Helper/DCCProductStatus.php @@ -103,6 +103,7 @@ class DCCProductStatus extends ProductStatus { continue; } + // Settings used as a cache; `settings->set` is compatible with new UI. if ( in_array( 'CUSTOM_CARD_PROCESSING', $product->capabilities(), true ) ) { $this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED ); $this->settings->persist(); diff --git a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php index 250138089..64192bd87 100644 --- a/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php +++ b/modules/ppcp-wc-gateway/src/Helper/PayUponInvoiceProductStatus.php @@ -96,6 +96,7 @@ class PayUponInvoiceProductStatus extends ProductStatus { continue; } + // Settings used as a cache; `settings->set` is compatible with new UI. if ( in_array( 'PAY_UPON_INVOICE', $product->capabilities(), true ) ) { $this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED ); $this->settings->persist(); diff --git a/modules/ppcp-wc-gateway/src/Settings/SettingsListener.php b/modules/ppcp-wc-gateway/src/Settings/SettingsListener.php index e6b6fa1b9..b612de369 100644 --- a/modules/ppcp-wc-gateway/src/Settings/SettingsListener.php +++ b/modules/ppcp-wc-gateway/src/Settings/SettingsListener.php @@ -263,6 +263,8 @@ class SettingsListener { // phpcs:enable WordPress.Security.NonceVerification.Missing // phpcs:enable WordPress.Security.NonceVerification.Recommended + // This method is only used for legacy UI, `settings->set` is valid here. + $this->settings->set( 'merchant_id', $merchant_id ); $this->settings->set( 'merchant_email', $merchant_email ); @@ -365,6 +367,8 @@ class SettingsListener { return; } + // This method is only used for legacy UI, `settings->set` is valid here. + try { $token = $this->bearer->bearer(); if ( ! $token->vaulting_available() ) { @@ -474,6 +478,10 @@ class SettingsListener { && 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] ); } + // This method initializes a feature cache. This initialization is not + // required by the new UI; we can ignore the `settings->set` usage. + // TODO new-ux: Test, if this method is called or some non-settings parts must be converted. + // phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing // phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing if ( $credentials_change_status ) { @@ -722,6 +730,8 @@ class SettingsListener { /** * Prevent enabling tracking if it is not enabled for merchant account. * + * This method is not used anywhere. Not relevant for new-ux. + * * @throws RuntimeException When API request fails. */ public function listen_for_tracking_enabled(): void { @@ -767,6 +777,8 @@ class SettingsListener { return; } + // This method is only used for legacy UI, `settings->set` is valid here. + $existing_setting_value = $this->settings->has( $setting_slug ) ? $this->settings->get( $setting_slug ) : null; if ( $condition ) {