🔄 Handle the Three D Secure setting migration in the options and remove legacy references

This commit is contained in:
Daniel Dudzic 2025-06-10 12:52:58 +02:00
parent 3cd4cda398
commit 9cde0ae11b
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
3 changed files with 34 additions and 21 deletions

View file

@ -71,6 +71,7 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
$this->migrate_pay_later_settings( $c );
$this->migrate_smart_button_settings( $c );
$this->migrate_three_d_secure_setting();
$this->fix_page_builders();
$this->exclude_cache_plugins_js_minification( $c );
@ -274,6 +275,38 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
);
}
/**
* Migrates the old Three D Secure setting located in PaymentSettings to the new location in SettingsModel.
*
* The migration will be done on plugin update if it hasn't already done.
*/
protected function migrate_three_d_secure_setting(): void {
$payment_settings = get_option('woocommerce-ppcp-data-payment') ?: array();
$data_settings = get_option('woocommerce-ppcp-data-settings') ?: array();
// Skip if payment settings don't have the setting but data settings do.
if ( ! isset( $payment_settings['three_d_secure'] ) && isset( $data_settings['three_d_secure'] ) ) {
return;
}
add_action(
'woocommerce_paypal_payments_gateway_migrate_on_update',
function () {
$payment_settings = get_option('woocommerce-ppcp-data-payment') ?: array();
$data_settings = get_option('woocommerce-ppcp-data-settings') ?: array();
// Move the setting.
$data_settings['three_d_secure'] = $payment_settings['three_d_secure'];
unset( $payment_settings['three_d_secure'] );
// Save both.
update_option('woocommerce-ppcp-data-settings', $data_settings);
update_option('woocommerce-ppcp-data-payment', $payment_settings);
}
);
}
/**
* Changes the button rendering place for page builders
* that do not work well with our default places.