
| Current Path : /var/www/html/store/web/modules/contrib/commerce_paypal/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/store/web/modules/contrib/commerce_paypal/commerce_paypal.install |
<?php
/**
* @file
* Contains install and update functions for Commerce PayPal.
*/
/**
* Install the PayPal Checkout payment method type.
*/
function commerce_paypal_update_8101() {
$entity_type = \Drupal::entityTypeManager()->getDefinition('commerce_payment_method');
\Drupal::service('entity.bundle_plugin_installer')->installBundles($entity_type, ['commerce_paypal']);
}
/**
* Install the PayPal Checkout payment method type.
*/
function commerce_paypal_update_8102() {
$entity_type = \Drupal::entityTypeManager()->getDefinition('commerce_payment_method');
\Drupal::service('entity.bundle_plugin_installer')->installBundles($entity_type, ['commerce_paypal']);
}
/**
* Move the credit messaging settings to a different config object.
*/
function commerce_paypal_update_8103() {
$config_factory = \Drupal::configFactory();
$legacy_config = $config_factory->getEditable('commerce_paypal.settings');
$client_id = $legacy_config->get('commerce_paypal.credit_messaging_client_id');
if ($client_id) {
$config = $config_factory->getEditable('commerce_paypal.credit_messaging_settings');
$config
->set('client_id', $client_id)
->set('add_to_cart', $legacy_config->get('commerce_paypal.credit_messaging_add_to_cart'))
->save();
$legacy_config->delete();
}
}
/**
* Disables credit card icon settings on existing payment gateways.
*/
function commerce_paypal_update_8104() {
$payment_gateways = \Drupal::entityTypeManager()
->getStorage('commerce_payment_gateway')
->loadMultiple();
foreach ($payment_gateways as $payment_gateway) {
if ($payment_gateway->getPluginId() !== 'paypal_checkout') {
continue;
}
$configuration = $payment_gateway->getPluginConfiguration();
$configuration['enable_credit_card_icons'] = FALSE;
$payment_gateway->setPluginConfiguration($configuration);
$payment_gateway->save();
}
}