Commit 11cd93c8 authored by Jingsheng Wang's avatar Jingsheng Wang Committed by Jonathan Sacksick
Browse files

Issue #3268199 by skyredwang, jsacksick, brunodbo: Remove PayPal Checkout from...

Issue #3268199 by skyredwang, jsacksick, brunodbo: Remove PayPal Checkout from the add payment method form options.
parent a13d7914
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -228,7 +228,6 @@ function commerce_paypal_form_commerce_order_item_add_to_cart_form_alter(&$form,
    return;
  }
  // Add Credit Messaging JS to the form.
  // @todo ensure messaging reapplies after an Ajax refresh.
  $form['#attached']['library'][] = 'commerce_paypal/credit_messaging';

  $form['paypal_credit_messaging_product'] = [
@@ -251,7 +250,9 @@ function commerce_paypal_js_alter(&$javascript, AttachedAssetsInterface $assets)
  if (!$client_id) {
    return;
  }
  $paypal_checkout_js = drupal_get_path('module', 'commerce_paypal') . '/js/paypal-checkout.js';
  /** @var \Drupal\Core\Extension\ExtensionPathResolver $extension_path_resolver */
  $extension_path_resolver = \Drupal::service('extension.path.resolver');
  $paypal_checkout_js = $extension_path_resolver->getPath('module', 'commerce_paypal') . '/js/paypal-checkout.js';
  // The paypal-checkout JS file isn't present, no need to do anything.
  if (!isset($javascript[$paypal_checkout_js])) {
    return;
@@ -264,3 +265,11 @@ function commerce_paypal_js_alter(&$javascript, AttachedAssetsInterface $assets)
    }
  }
}

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function commerce_paypal_form_commerce_payment_method_add_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // The current PayPal checkout implementation doesn't support tokenization.
  unset($form["payment_method"]["#options"]["new--paypal_checkout--paypal"]);
}