Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Cart
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 May 2017 at 22:51 UTC
Updated:
11 Oct 2019 at 10:53 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
bojanz commentedOuch, agreed.
Comment #3
vasikehere is patch for this.
Used the D7 approach - extra JS for edit quantity Views handler - to make sure the Update cart is submitted on press enter key.
Comment #4
sorabh.v6Comment #5
sorabh.v6Hi All,
I confirm that the patch in #3 is working fine for me code is also looking fine. Setting it to RTBC.
Thanks All
Comment #6
megachrizWould this still work when #2906345: Replace the cart page view with a Twig template lands?
I see a reference to a views class here:
Comment #7
edurenye commentedRTBC +1
Comment #8
littlepixiez commented#3 works perfectly for me. It's the first thing I did when playing with the cart! Great patch.
@MegaChriz It works using 'form input[id^="edit-edit-quantity"]' but I'm guessing the ID might change depending on what generates the form?
Comment #9
spacetaxi commented#3 works for me with a minor change: Add a colon (:) in front of input in the selector. See https://api.jquery.com/input-selector/
to
Comment #10
abrammThe JS code is missing context handling and once().
Running Drupal.attachBehaviors() multiple time will cause the event handler to run multiple times.
Comment #11
abrammAhh the context handling is there. That's just once() missing.
Here's the patch against latest dev.
Added once() and changed input to :input as per #9.
Interdiff included.
Comment #12
abrammComment #13
berdirDon't know too much about JS, but this was RTBC before, looks fine to me and I tested it.
Interestingly, after noticing this problem. I quickly tried to reproduce on https://commerceplus.acromedia.com/cart and it doesn't happen there, so I first thought its a problem with our theme, but I guess this patch is already applied there...
Comment #14
bojanz commentedThanks everyone!
Let's call this cart_form. That parallels cart_block above it, and allows us to keep the file even for a Twig version of the cart form, if it ends up existing. The JS file should then be commerce_cart.form.js (not a fan of prefixing every JS/CSS file with the module name, but that's what we've done so far).
Indentation is wrong here.
Wanted to run a full ESLint, but it's ignoring Drupal's coding standard somehow, telling me to replace single quotes with double quotes, which makes no sense.
Comment #16
bojanz commentedThanks, everyone!
Comment #17
mmjvb commentedComment #19
eiriksmNot sure if we should call this an edge case, but the selector in the jQuery code will only work if you actually use the view provided by commerce core with little customization. This means one has to duplicate this code to be able to fix the same issue when the selectors are different.
In my opinion we should add a class to the actual input instead, and use this as the selector. This way, the code would work regardless of how you customize the cart form. Well except if you actively remove this class, but that seems way less likely than someone doing some customization that ends up changing wrapper selectors.
Here is a patch with that approach. If you want a followup instead, please let me know :)
Comment #20
eiriksmAdded a follow up and marked as related