Skip to content

Enforce minimum unit quantity of 1 in product variant form#2547

Open
Huncsuga wants to merge 2 commits into
lunarphp:1.xfrom
Huncsuga:fix/unit-quantity-minimum-validation
Open

Enforce minimum unit quantity of 1 in product variant form#2547
Huncsuga wants to merge 2 commits into
lunarphp:1.xfrom
Huncsuga:fix/unit-quantity-minimum-validation

Conversation

@Huncsuga

@Huncsuga Huncsuga commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

This PR prevents the Unit Quantity field from accepting values lower than 1.

This avoids invalid inventory configurations that can cause a DivisionByZeroError when adding a product or product variant to the cart.

Fixes #2546

Add minValue(1) to the unit quantity form field on ProductVariantResource
and clamp DefaultPriceFormatter's unitQty to 1 in the constructor, so a
zero or negative value can't be entered or divided by when computing
unit prices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Unit Quantity can be set to zero, causing a DivisionByZeroError when adding the product to the cart

1 participant