Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Cart
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2020 at 17:42 UTC
Updated:
6 Aug 2020 at 14:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mglamanBlind patch to at least scaffold out what the code should kind of look like.
Comment #3
mglamanComment #4
jsacksick commentedI've been working on this today, we should definitely fix this ASAP, cause right now, if an order availability checker indicates that an order item is unavailable, the quantity update goes through, and then the item is removed on the next refresh (with a successful message saying "Your shopping cart has been updated").
I tried finding an issue for that this morning but couldn't, and then finally found yours :p.
We need tests coverage for this, and we also need to set the initial quantity back, so the logic in
viewsFormSubmit()works properly.For some reason, when looping over the violations using the
getEntityViolations(), no violations are present. so I'm looping on the violations directly and it seems to work.Attaching patch for review.
Comment #5
jsacksick commentedComment #6
mglaman😂 had to find this, man.. Views.
Above we check
$quantity < 0and here we check if it is also equal to0. The could still mean the quantity changed. Should we changeto
and update the inline comments? This handles invalid values or purposely set to 0 quantities?
I don't think we need to filter by field access if we are then filtering by the two specified fields
Is this required? This isn't a content entity form, so I don't think this affects anything.
And, upon further digging.. it looks like this flag is mostly used when importing entities via Migrate, not even the content entity form.
Actually, we could remove this and just update
viewsFormSubmitto trust the set quantity value. We've validated it already, so the form submit no longer needs to.Comment #7
jsacksick commentedWell, we can't remove the checks in
viewsFormSubmit()becauseviewsFormValidateignore "invalid" quantities and doesn't throw an error.And we still need
to keep ignoring quantities that haven't changed. Remember, we're checking quantities of all "rows", not just a single one.Comment #8
mglamanAh okay. Thanks @jsacksick for clarifying Views form handling 🙂.
Moving to RTBC as my sign off, if you'd like the honors of commit.
Comment #10
jsacksick commentedCommitted!