Skip to content
Snippets Groups Projects
Commit 82bde850 authored by Romain Derie's avatar Romain Derie
Browse files

[FIX] website_sale(_options): text in field qty throws error and/or create infinite quotations

Before this commit:
1. If user wrote text in the quantity field to add to his cart, it would crash
and show a server error.

Now, if the user insert a non-valid quantity in the field, we set it to 1

Step to reproduce:
With website_sale only
  - Go to a product page on the shop
  - Insert 'abc' in the quantity field and click 'Add to Cart'
  - Server will throw an error 'Can't parse float..'
With website_sale_options
  - Go to a product page on the shop
  - Insert 'abc' in the quantity field and click 'Add to Cart'
  - Popup confirmation with optional product will show with 'NaN' in the qty
  - Click 'Proceed to checkout'
  - Server will throw an error 'Can't parse int..'

2. On the checkout, if user typed text in qty field it would create infinite
quotations.
Some modules (eg: website_event_sale) would hide this behavior because they
override the RPC call to '/shop/cart/update_json' and throw an error on the
RPC.

Now, if user type incorrect integer quantity, we set the quantity to 1.

Step to reproduce:
1. On base (website_sale only)
  - Add an item to your cart
  - On checkout page, set qty to 'abcd' or whatever text
  - Check your browser console, every 500ms their will be a RPC call
  - Check your quotations in backend, their will be a new one every 500ms
2. On db-all
  - Add an item to your cart
  - Set qty to 'abcd' or whatever text
  - Check your browser console, it will throw an error on the second call

This closes #20482, closes #20904
parent 832d73de
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment