Skip to content

Prevent stock input field from accepting negative stock values #714

@TresBlue

Description

@TresBlue

Which component is this issue related to?

Umbraco Commerce (Core)

Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)

13.2.2

Bug summary

We've build a third party stock synchronisation for one of our commerce projects. Our clients sometimes have negative stock when too much is ordered and is put on backorder to their suppliers.

When syncing we've noticed that the negative numbers are saved in the Umbraco content, but not in the stock database table of the products itself. This value is reset to the old value.

Even when trying to set the stock to a negative number in the backoffice and pressing save and publish, there are no errors or warnings, to our clients it looks like saving is successfull and the value only resets after refresing/reopening the page.

After debugging a bit we found the cause of the issue.

Specifics

Code debug
Image

Steps to reproduce

Create a product in content with the commerce stock property. Change the value to a positive number and saveandpublish. Then change it to a negative number, saveandpublish, refresh page, old value.

Check the umbraco property database, stock is the negative number. Check the commerce stock database, stock is the old positive number.

Expected result / actual result

Most optimal for us would be negative stock. If this is not possible at least some frontend validation/warnings would be nice.

We think the stock being properly set in content but not in the stock table is potentially dangerous, maybe revert the content value to the old positive number too, than the values will stay the same.

Dependencies

No response


This item has been added to our backlog AB#53385

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions