Problem/Motivation
Currently if we update cart with 0 count, then item is removed from cart. I have not tested with less than zero count but I think it may break the functionality.
Proposed resolution
Handle less than 0 update count. If 0 or less than 0 update count is entered, the item will be removed from cart.
Update the condition inside dc_ajax_add_cart_update_quantity_refresh():
// If altered quantity is not zero, then update line item's quantity.
// Otherwise delete line item.
if ($form_state['values']['quantity_' . $form_state['triggering_element']['#line_item_id']] != 0) {
...
}
else {
...
}
Remaining tasks
Make the changes and commit it.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #2
subhojit777Comment #3
subhojit777Comment #4
visabhishek commentedHi subhojit777,
I tried to break the functionality with some negative value, but there is validation for negative value. So i am closing this issue.
Comment #5
subhojit777Where you are checking this? From the image I guess it's "/cart" page. That validation will only work for that form, not in the ajax block that is provided by the module.
Comment #6
visabhishek commentedHi subhojit777,
Sorry, that was my mistake, i was checking on wrong place.
As per suggestion i am uploading a patch to remove product from cart, if quantity is less then or equal to zero.
Comment #8
subhojit777I've tried adding product with 0 and -1 quantity, and I saw an error message:
I was not able to add product to cart with invalid quantity.
I guess this was fixed in #2362869: Respect required fields on add to cart form