mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
💡 Document use of “settings->set()” via comments
This commit is contained in:
parent
a13b8c03ff
commit
9f44657400
10 changed files with 25 additions and 1 deletions
|
@ -89,6 +89,7 @@ class AppleProductStatus extends ProductStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings used as a cache; `settings->set` is compatible with new UI.
|
||||||
if ( $has_capability ) {
|
if ( $has_capability ) {
|
||||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -272,8 +272,9 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function toggle_final_review_enabled_setting(): 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->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();
|
$this->settings->persist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ class ApmProductStatus extends ProductStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings used as a cache; `settings->set` is compatible with new UI.
|
||||||
if ( $has_capability ) {
|
if ( $has_capability ) {
|
||||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -71,6 +71,7 @@ class LocalApmProductStatus extends ProductStatus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings used as a cache; `settings->set` is compatible with new UI.
|
||||||
if ( $has_capability ) {
|
if ( $has_capability ) {
|
||||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -95,6 +95,7 @@ class SaveConfig {
|
||||||
* @param array $config The configurator config.
|
* @param array $config The configurator config.
|
||||||
*/
|
*/
|
||||||
public function save_config( array $config ): void {
|
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_enable_styling_per_messaging_location', true );
|
||||||
$this->settings->set( 'pay_later_messaging_enabled', true );
|
$this->settings->set( 'pay_later_messaging_enabled', true );
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ class SettingsCommand {
|
||||||
$value = false;
|
$value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO new-ux: The setting must also be updated in the new settings.
|
||||||
$this->settings->set( $key, $value );
|
$this->settings->set( $key, $value );
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,10 @@ class PayUponInvoice {
|
||||||
*/
|
*/
|
||||||
public function init(): void {
|
public function init(): void {
|
||||||
if ( $this->pui_helper->is_pui_gateway_enabled() ) {
|
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->set( 'fraudnet_enabled', true );
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ class DCCProductStatus extends ProductStatus {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings used as a cache; `settings->set` is compatible with new UI.
|
||||||
if ( in_array( 'CUSTOM_CARD_PROCESSING', $product->capabilities(), true ) ) {
|
if ( in_array( 'CUSTOM_CARD_PROCESSING', $product->capabilities(), true ) ) {
|
||||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
|
|
|
@ -96,6 +96,7 @@ class PayUponInvoiceProductStatus extends ProductStatus {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings used as a cache; `settings->set` is compatible with new UI.
|
||||||
if ( in_array( 'PAY_UPON_INVOICE', $product->capabilities(), true ) ) {
|
if ( in_array( 'PAY_UPON_INVOICE', $product->capabilities(), true ) ) {
|
||||||
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
$this->settings->set( self::SETTINGS_KEY, self::SETTINGS_VALUE_ENABLED );
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
|
|
|
@ -263,6 +263,8 @@ class SettingsListener {
|
||||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
// 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_id', $merchant_id );
|
||||||
$this->settings->set( 'merchant_email', $merchant_email );
|
$this->settings->set( 'merchant_email', $merchant_email );
|
||||||
|
|
||||||
|
@ -365,6 +367,8 @@ class SettingsListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method is only used for legacy UI, `settings->set` is valid here.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$token = $this->bearer->bearer();
|
$token = $this->bearer->bearer();
|
||||||
if ( ! $token->vaulting_available() ) {
|
if ( ! $token->vaulting_available() ) {
|
||||||
|
@ -474,6 +478,10 @@ class SettingsListener {
|
||||||
&& 1 === absint( $_POST['woocommerce_ppcp-gateway_enabled'] );
|
&& 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
|
||||||
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
// phpcs:enable phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||||
if ( $credentials_change_status ) {
|
if ( $credentials_change_status ) {
|
||||||
|
@ -722,6 +730,8 @@ class SettingsListener {
|
||||||
/**
|
/**
|
||||||
* Prevent enabling tracking if it is not enabled for merchant account.
|
* 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.
|
* @throws RuntimeException When API request fails.
|
||||||
*/
|
*/
|
||||||
public function listen_for_tracking_enabled(): void {
|
public function listen_for_tracking_enabled(): void {
|
||||||
|
@ -767,6 +777,8 @@ class SettingsListener {
|
||||||
return;
|
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;
|
$existing_setting_value = $this->settings->has( $setting_slug ) ? $this->settings->get( $setting_slug ) : null;
|
||||||
|
|
||||||
if ( $condition ) {
|
if ( $condition ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue