Skip to content

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

Description

@Huncsuga
  • Lunar version: 1.5.0-beta.6
  • Laravel Version: 12.62.0
  • PHP Version: 8.4.22
  • Database Driver & Version: MariaDB 10.11.18

Expected Behaviour:

The Unit Quantity field on the Inventory tab should not accept values lower than 1.

The field should have a minimum value validation of 1, preventing invalid inventory configurations that can cause division by zero errors.

Actual Behaviour:

The Unit Quantity field currently accepts 0.

When In Stock is set to a value greater than 0 and Unit Quantity is set to 0, attempting to add the product or product variant to the cart results in the following error:

DivisionByZeroError
Division by zero
Image Image

Steps To Reproduce:

  1. Open a product or product variant in the Lunar admin panel.
  2. Navigate to the Inventory tab.
  3. Set In Stock to a value greater than 0.
  4. Set Unit Quantity to 0.
  5. Save the changes.
  6. Attempt to add the product or product variant to the cart.
  7. Observe that a DivisionByZeroError is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions