Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eddiedale opened this issue Mar 10, 2025 · 5 comments
Open

Comments

@eddiedale
Copy link

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

Copy link

linear bot commented Mar 10, 2025

@lukeholder
Copy link
Member

@eddiedale Inventory is only committed when the order is completed. Manually editing an order after the order is complete does not adjust stock, so you would need to do that manually if you make a manual edit to an order after it is complete. The only way to adjust stock related to the order at the moment is to fulfil the committed stock with the fulful button action.

having said that, we do see a need to support this in the future.

Would you expect to have the option to adjust the stock on each save of the order? What would you expect to happen to the original committed stock made at order completion, would you expect it to be committed immediately on order save?

@lukeholder lukeholder added Feature 💡 enhancement Ideas and suggestions and removed bug labels Mar 12, 2025
@eddiedale
Copy link
Author

@lukeholder Thanks for the clarification!

It sounds from your explanation that changing a completed order does not change any stock-values at all, but from my testing that seems incorrect. It does indeed remove the committed stock and bring that back to availability. It just does not decrease the available stock/ add committed stock on the newly added product.

It feels like an unclear case of either/or. The removal gets handled as expected, but the added product not.

And furthermore it's confusing that it only changes back the stock on the originally added product on the first order change, but not on subsequent changes. Then no changes are made to stock at all (as you describe as the default behavior)

I would expect that upon order update, it would bring whatever was committed but is now removed from the order to be brought back into availability + the newly added products to be added as committed and decrease the available stock of it.
This is also the expected behavior from my client.
Right now they manually go in and decrease the newly added product, but don't increase the stock of the originally added product.

@eddiedale
Copy link
Author

eddie-12-03-2025-09.22.09.mp4

@lukeholder

@lukeholder
Copy link
Member

@eddiedale OK, so deleting the line item will remove the stock transactions (reduce available and add to committed) associated with the line item as you can see. If you had just increased or decreased the stock value for that line item it wouldn't have done anything to the stock counters.

This isn't ideal but its the way it works for now.

Will keep this ticket open as we discuss our proposed improvements internally.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants