Skip to content

[5.x]: Changing line items multiple times not updating stock as expected #3922

@eddiedale

Description

@eddiedale

What happened?

Description

When changing an order in the control panel:
1x Line Item X removed and 1x Line Item Y added.

This will correctly increment the stock value of Line Item X, but not decrement the stock value of Line Item Y.

Furthermore if this order is updated, and the process is done again (reverted) neither value will be updated.

Steps to reproduce

  1. Complete an order of an item (Item X)
  2. Check stock values of Item X and Item Y (before values)
  3. Edit the order, and remove the line item (Item X) and add Item Y instead.
  4. See that Item X correctly has one more available, but Y is unchanged
  5. Go back to the order, and remove Item Y, and add Item X
  6. See that neither of the stock values are changed.
  7. The same happens with simply removing the items from the order, or adding any other item (Item Z). This will not decrement stock values.

Expected behavior

One would reasonably expect that adding a line item decrements its stock value, and that removing a line item increments the availability of it.

Craft CMS version

5.6.6

Craft Commerce version

5.3.2.2

PHP version

8.3.16

Operating system and version

No response

Database type and version

MySQL 8.0.41

Image driver and version

No response

Installed plugins and versions

Craft Commerce 5.3.2.2
Freeform 5.9.10
Redactor 4.2.0
SEOmatic 5.1.11
Stripe for Craft Commerce 5.0.6
Table Maker 5.0.4

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions