Prestashop: Bad behavior with qty and add to cart

Created on 24 Aug 2018  路  16Comments  路  Source: PrestaShop/PrestaShop

Reminder

DO NOT create security issues here, but contact [email protected] instead!

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to any page of a product
  2. Inset empty value in qty field.
  3. Click on 'Add to cart'
  4. There are not added any product to the cart. In case the theme use a spinning icon while add products to cart, this icon will spin until you reload the page.
    The behavior is wrong. In case of empty qty field, when click on add to cart, the qty field should increase to 1 and add 1 to cart.

Screenshots
screenshot
When click on add to cart, the value should change from empty to 1 and add 1 pcs to cart.

Additionnal information
PrestaShop version: 1.7.3
PHP version: 7.1.x

1.7.4.2 1.7.6.0 Blockcart Bug FO Fixed Minor PM 鉁旓笍

Most helpful comment

Hi @Mreker,

I manage to reproduce the issue with the last version PS:1.7.4.2
We will see how to fix it.

Best regards,
Khouloud

All 16 comments

Hi @Mreker,

I manage to reproduce the issue with the last version PS:1.7.4.2
We will see how to fix it.

Best regards,
Khouloud

@colinegin what do you think of this improvement suggestion ?

Same bahavior as on 1.6, I'm ok for it. But i'm not sure of the consequences of such a change.
@eternoendless do you think there could be any impact if we implement this fix ?

I don't think a fix would have any negative consequences

If someone click on "add to cart" they might expect a value greater than 0.

Invalid values like "-1", "0", "a" are already coerced into "1". An easy fix would be to apply that same coercion to "empty string" too. Coercing the value in the input is better than guesswork in many levels, including that it provides visual cues for the user to know how many items he or she will be adding to their cart.

I don't think there's any particular risk attached to such a change since we already do it for other invalid values.

@eternoendless watch out. If you want to add "20" pcs then you will need to be able to empty the field and type it in. Therefore the value should not automatic change to "1" if the value is empty.

The change from empty to "1" should be done only in case of "add to cart" is clicked.

So it is not exactly the same trigger.

Wdyt?

Any news on this?

Hi @MathiasReker,
Currently if we write 0 it becomes the minimum quantity for sale specified by the merchants in product page(BO).

If we delete everything and click out of the input, it should display the minimum quantity for sale

If we are editing the input, anything will happened in order to let users write a number (superior or equal to the minimum quantity for sale).

So
1) In product page (FO) we should transform empty field to minimum quantity for sale (defined in product page in BO).
2) In product page (BO)>Quantities>minimum quantity for sale
we shouldn't let merchants write 0 (transform it to 1).

tell me what you think about it @colinegin

@BilalDr yes, and if quantity = "" and we click 'add to cart' the quantity should change to "1"

@MathiasReker more precisely, it should add the minimum quantity defined in the product configuration (1 if this is the classic minimum quantity, but if there is a specific configuration, with at least 5 products, it should add 5 products to the cart).

Do you agree ?

agreee on that @colinegin 馃憤

Great ! Thank you all :)

Is this removed from to do in PS 1.7.6?

watch out. If you want to add "20" pcs then you will need to be able to empty the field and type it in. Therefore the value should not automatic change to "1" if the value is empty.

Of course, data coercion should be performed on input blur (after it loses focus) to account for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiousi picture hiousi  路  3Comments

khouloudbelguith picture khouloudbelguith  路  3Comments

sandra2n picture sandra2n  路  3Comments

vincent-dp picture vincent-dp  路  3Comments

Fabuloops picture Fabuloops  路  3Comments