PrestaShop / hummingbird

79 stars 74 forks source link

Fix: when you edit the product qty to zero, the product won't be removed from the cart #542

Closed tblivet closed 1 year ago

tblivet commented 1 year ago
Questions Answers
Description? Correct the issue 536
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes https://github.com/PrestaShop/hummingbird/issues/536
Sponsor company @PrestaShopCorp
How to test? You can refer to the issue
SharakPL commented 1 year ago

IMO it would be better to simply disallow changing quantity to 0. This can be done by mistake and then the product would have to be searched again. If a user wants to remove the product from the cart then the Remove button should be clicked.

Hlavtox commented 1 year ago

@SharakPL That was how it was before. It should throw an error message "Minimal quantity for sale is 1".

Also, it's a bit incosistent. What does it do if minimum quantity for sale is higher than 1? 🤔

I am a bit torn apart for the expected behavior here.

SharakPL commented 1 year ago

@sallemiines could you please check again with product that has minimum order quantity higher than 1? It doesn't look like it's covered.

kpodemski commented 1 year ago

@tblivet Related function in Classic is inside:

themes/classic/_dev/js/cart.js in updateProductQuantityInCart function.

if (targetValue === '0') {
      $target.closest('.product-line-actions').find('[data-link-action="delete-from-cart"]').click();
    } else {
      $target.attr('value', targetValue);
      sendUpdateQuantityInCartRequest(updateQuantityInCartUrl, getRequestData(qty), $target);
    }

It looks that instead of checking minimal quantity you should only check whether the target value is equal to 0.

SharakPL commented 1 year ago

Is there a place for improvements or does it have to be done like in Classic?

kpodemski commented 1 year ago

@SharakPL what would be an improvement in your opinion?

SharakPL commented 1 year ago

To be more clear on what each action does. Decreasing the amount shouldn't delete the product from the cart. If the requested amount is lower than the minimum required for order then it should throw an error:

The minimum amount required for order of this product is X. If you want to remove the product completely from your cart then use the Remove button

Or at least change [ - ] to [ X ] or [ trash_icon ] to indicate that next use of this button will remove it completely instead of just decreasing the amount. Especially useful if the minimum required amount is higher than 1.

kpodemski commented 1 year ago

The one improvement I see in this change is that if one makes a mistake and changes the value below 1, it could save the cart. I've checked a few stores, and when there are arrows, changing below 1 is forbidden. There's no request, which could also be a good thing.

Something to be decided by @PrestaShop/product-council :)

To summarize:

SharakPL commented 1 year ago

I've checked a few stores, and when there are arrows, changing below 0 is forbidden.

Did you mean "below 1"?

kpodemski commented 1 year ago

@SharakPL yes, I edited the message

RosaBenouamer commented 1 year ago

Hello, On Amazon : image You have a text next to 0 which precise that by clicking on 0 you will suppress the article image I find it's quite a good idea. Concerning the case where you have a minimum of quantity to order to validate it. I imagine for instance, if you have to order minimum of 30. The list in the arrow will be 0 to let to suppress then directly 30,31,32...

Hlavtox commented 1 year ago

@RosaBenouamer There needs to be a number input, dropdown for selecting count is not good UX. :-)

tblivet commented 1 year ago

Hello 👋 With @ga-devfront we have update the PR we now have this behavior :

ga-devfront commented 1 year ago

No response from the people who blocked the PR, additions were made and the behavior seems to be the most common to web standards: Impossible to go below the minimum orderable unless it is 0 in which case the product is deleted. I pass the PR to Waiting for QA