craftcms / craftcms/commerce

Changing line items multiple times not updating stock as expected

Open
#3,922 7 comments 0 reactions 1 assignee View on GitHub

@lukeholder is already working on this.

Since Mar 12, 2025.

Craft Commerce Feature
Dominant language
PHP
Stars
240
Forks
173
Avg merge
5d 11h
Merged PRs (30d)
8

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.