[19.0][ADD] website_sale_product_multiple_qty#4165
[19.0][ADD] website_sale_product_multiple_qty#4165
Conversation
6067d01 to
e7d99f1
Compare
73eccbc to
79e2dc1
Compare
ivantodorovich
left a comment
There was a problem hiding this comment.
LG, thanks @yankinmax !
Would it be possible to add a test tour with a simple test case?
| # The website expects an integer value as an input | ||
| # ``website_sale::variant_mixin.js`` | ||
| # parseInt(parent.querySelector('input[name="add_qty"]').value). | ||
| "multiple_qty": int(rounded_qty), |
There was a problem hiding this comment.
nitpicking: I suggest math.ceil here, to always round-up instead of down; or round(rounded_qty, 0)
There was a problem hiding this comment.
We want to be able to round "DOWN" also.
There was a problem hiding this comment.
Go for round(rounded_qty, 0) then which would get the best outcome I guess.
There was a problem hiding this comment.
It doesn't make any sense to add float rounding here if int is expected:
When the page is refreshed/opened we have the number rounded with zero decimal.
Adding the quantity increases to an integer.
const combinationInfo = await this.waitFor(rpc('/website_sale/get_combination_info', {
'product_template_id': parseInt(parent.querySelector('.product_template_id')?.value),
'product_id': this._getProductId(parent),
'combination': combination,
'add_qty': parseInt(parent.querySelector('input[name="add_qty"]')?.value),
'uom_id': this._getUoMId(parent),
'context': this.context,
...this._getOptionalCombinationInfoParam(parent),
}));
There was a problem hiding this comment.
int(round(rounded_qty, 0)) then
int alone would result in, for example 1.999 -> 1.
Essentially takes only the integer part, ignoring all decimals.
with round, 1.999 -> 2
f79cc81 to
d479913
Compare
d479913 to
5f740b3
Compare
This module extends the eCommerce flow to support Sales Multiples
(packaging quantities) directly on the product page, in the cart,
and in the product configurator.
When a product (or variant) has a Sales Multiple configured,
the quantity entered by the customer on the website is automatically
rounded to a valid multiple according to the interaction type.
The rounding logic is applied dynamically when the customer: