diff -u b/modules/cart/js/commerce_cart_edit_quantity.js b/modules/cart/js/commerce_cart_edit_quantity.js --- b/modules/cart/js/commerce_cart_edit_quantity.js +++ b/modules/cart/js/commerce_cart_edit_quantity.js @@ -13,11 +13,13 @@ attach: function (context) { // Click the update button, not the remove button on enter key if we are // on a text field. - $('form .views-field-edit-quantity input.form-number', context).keydown(function (event) { + $('form .views-field-edit-quantity input.form-number', context) + .once('commerce-cart-edit-quantity') + .keydown(function (event) { if (event.keyCode === 13) { // Prevent browser's default submit from being clicked. event.preventDefault(); - $('input#edit-submit', $(this).parents('form')).click(); + $(':input#edit-submit', $(this).parents('form')).click(); } }); } diff -u b/modules/cart/src/Plugin/views/field/EditQuantity.php b/modules/cart/src/Plugin/views/field/EditQuantity.php --- b/modules/cart/src/Plugin/views/field/EditQuantity.php +++ b/modules/cart/src/Plugin/views/field/EditQuantity.php @@ -137,10 +137,6 @@ } // Replace the form submit button label. $form['actions']['submit']['#value'] = $this->t('Update cart'); - // Add JS for triggering the Update button when hitting the enter key. - $form['#attached'] = [ - 'library' => ['commerce_cart/edit_quantity'], - ]; } /** @@ -168,6 +164,10 @@ $form['actions']['submit']['#show_update_message'] = TRUE; // Replace the form submit button label. $form['actions']['submit']['#value'] = $this->t('Update cart'); + // Add JS for triggering the Update button when hitting the enter key. + $form['#attached'] = [ + 'library' => ['commerce_cart/edit_quantity'], + ]; } /**