jQuery error on checkout

Created on 21 February 2023, almost 2 years ago
Updated 29 March 2023, over 1 year ago

I installed latest stable version of Drupal 10 and Drupal Commerce. Created new sub-theme using this command:
# php core/scripts/drupal generate-theme <theme-name>

I configured PayPal gateway and my checkout page is not working - I can't enter any credit card credentials.
In console I see the error:

Uncaught TypeError: jQuery(...).attr(...) is undefined

$form.find(':input[name^="payment_information[add_payment_method][billing_information][address][0][address]"]').each(() => {
        // Extract the address field name.
        let name = jQuery(this).attr('name').split('['); <<< THIS LINE
        name = name[name.length - 1];
        billingInfo.address[name.substring(0, name.length - 1)] = $(this).val();
});

But on the page source I can see that jQuery is injected. Here is my last part of a page source, right near the :

<script src="/core/assets/vendor/jquery/jquery.min.js?v=3.6.3"></script>
<script src="/core/assets/vendor/once/once.min.js?v=1.0.1"></script>
<script src="/core/misc/drupalSettingsLoader.js?v=10.0.3"></script>
<script src="/core/misc/drupal.js?v=10.0.3"></script>
<script src="/core/misc/drupal.init.js?v=10.0.3"></script>
<script src="/core/assets/vendor/tabbable/index.umd.min.js?v=6.0.1"></script>
<script src="/core/misc/debounce.js?v=10.0.3"></script>
<script src="/core/misc/form.js?v=10.0.3"></script>
<script src="/modules/contrib/commerce/modules/promotion/js/commerce_promotion.coupon_redemption_form.js?v=10.0.3"></script>
<script src="/core/assets/vendor/jquery-form/jquery.form.min.js?v=4.3.0"></script>
<script src="/core/misc/progress.js?v=10.0.3"></script>
<script src="/core/assets/vendor/loadjs/loadjs.min.js?v=4.2.0"></script>
<script src="/core/misc/ajax.js?v=10.0.3"></script>
<script src="/modules/contrib/commerce_paypal/js/paypal-checkout-custom-card-fields.js?rq713s"></script>
<script src="/modules/contrib/commerce/modules/cart/js/commerce_cart.js?v=10.0.3"></script>
  </body>

The file jquery.min.js is not broken, it has a minified version of jQuery.

Please advice how to fix it.
thx

🐛 Bug report
Status

Fixed

Version

1.0

Component

PayPal Checkout

Created by

Live updates comments and jobs are added and updated live.
  • jQuery

    Affects the version, handling, or usage of the jQuery javascript library.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024