If a user puts an item into their cart and then while shopping the item goes out of stock it can be impossible for them to remove the item from their cart because when they do an error message will be given: "We're sorry. The product X is out of stock."
Attached patch ensures stock validation is not run when items are being removed from cart by remove button or by updating qty to 0.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 1299466-5-remove-out-of-stock-items.patch | 2.96 KB | hanoii |
| allow-remove-out-of-stock.patch | 1.03 KB | jrust |
Comments
Comment #1
hanoiiWould this patch still works with the checkbox approach of ubercart 2.4?
Comment #2
jrust commentedIt certainly wouldn't break things in 2.4, because it just makes sure not to run the validation if the remove button is clicked. If there is no remove button in the form, then this patch doesn't affect anything. However, it could be that out-of-stock items in UC 2.4 might not be able to be removed via the checkbox method, but they could still change the qty to 0.
Comment #3
hanoiiwrongly fixed in #1276484: User can edit the amount of product even it's out of stock
Comment #4
hanoiiDo you think is there any chance form_state['clicked_button']['#name'] is empty and that I might have to actually run validation.
I don't think so, but I prefer to only add the conditions that are necessary.
Maybe
is enough.
I am going with that, see if you have any opinions. I have changed/added some comments and also move the qty > 0 condition you have added a little bit above the code for not running a function that's not necessary, can you try this patc
Comment #5
hanoiiI am committing this patch, can you please try it out, if it works I will release a new version with this and another bug fixes reported since 1.6
Comment #6
jrust commentedPatch looks good -- I just added the !empty() check to avoid an undefined index notice out of habit, but I doubt it's necessary unless running E_STRICT. Thanks for committing.
Comment #7
hanoiiComment #8
dsbrianwebster commentedTested this patch. It applied smoothly and the issue was resolved.