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

subhojit777 created an issue. See original summary.

subhojit777’s picture

Issue tags: +Novice
subhojit777’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
visabhishek’s picture

Status: Needs work » Closed (works as designed)
StatusFileSize
new90.75 KB

Hi subhojit777,

I tried to break the functionality with some negative value, but there is validation for negative value. So i am closing this issue.

subhojit777’s picture

Status: Closed (works as designed) » Needs work

Where 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.

visabhishek’s picture

Status: Needs work » Needs review
StatusFileSize
new814 bytes

Hi 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.

Status: Needs review » Needs work

The last submitted patch, 6: product_to_be_removed-2568899-6.patch, failed testing.

subhojit777’s picture

Status: Needs work » Closed (cannot reproduce)

I've tried adding product with 0 and -1 quantity, and I saw an error message:

You must specify a valid quantity to add to the cart.

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