migrate( $card_settings ); } /** * Does the actual migration as described in the class docblock. * * @param array $card_settings The card gateway settings. */ private function migrate( $card_settings ) { // Get old settings with defaults. $payment_request_locations = $card_settings['payment_request_button_locations'] ?? self::LOCATIONS; $woopay_locations = $card_settings['platform_checkout_button_locations'] ?? self::LOCATIONS; // Build new location-centric settings. foreach ( self::LOCATIONS as $location ) { $methods = []; if ( in_array( $location, $payment_request_locations, true ) ) { $methods[] = 'payment_request'; } if ( in_array( $location, $woopay_locations, true ) ) { $methods[] = 'woopay'; } $card_settings[ "express_checkout_{$location}_methods" ] = $methods; } // Remove old settings. unset( $card_settings['payment_request_button_locations'] ); unset( $card_settings['platform_checkout_button_locations'] ); update_option( 'woocommerce_woocommerce_payments_settings', $card_settings ); } }