Skip to content

[19.0][ADD] website_sale_product_multiple_qty#4165

Open
yankinmax wants to merge 3 commits intoOCA:19.0from
camptocamp:add-website_sale_product_multiple_qty
Open

[19.0][ADD] website_sale_product_multiple_qty#4165
yankinmax wants to merge 3 commits intoOCA:19.0from
camptocamp:add-website_sale_product_multiple_qty

Conversation

@yankinmax
Copy link
Contributor

@yankinmax yankinmax commented Feb 19, 2026

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:

  • Opens the product page
  • Changes the product variant
  • Clicks the "+" (increase) button
  • Clicks the "–" (decrease) button
  • Manually enters a quantity
  • Presses Enter inside the quantity input
  • Changes quantities in the cart

@yankinmax yankinmax force-pushed the add-website_sale_product_multiple_qty branch from 6067d01 to e7d99f1 Compare February 19, 2026 15:25
@yankinmax yankinmax force-pushed the add-website_sale_product_multiple_qty branch from 73eccbc to 79e2dc1 Compare February 20, 2026 09:58
Copy link
Contributor

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking: I suggest math.ceil here, to always round-up instead of down; or round(rounded_qty, 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to be able to round "DOWN" also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go for round(rounded_qty, 0) then which would get the best outcome I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

scrnli_OYs4nJqev6Nh1j
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),
}));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@yankinmax yankinmax force-pushed the add-website_sale_product_multiple_qty branch 6 times, most recently from f79cc81 to d479913 Compare February 24, 2026 16:01
@yankinmax yankinmax force-pushed the add-website_sale_product_multiple_qty branch from d479913 to 5f740b3 Compare February 25, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants