mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
🔄 Handle the Three D Secure setting migration in the options and remove legacy references
This commit is contained in:
parent
3cd4cda398
commit
9cde0ae11b
3 changed files with 34 additions and 21 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue