Skip to content

fix(plugin-ecommerce): sync inventory to latest version with drafts#16525

Open
nehaaprasaad wants to merge 1 commit intopayloadcms:mainfrom
nehaaprasaad:fix/plg-eco-conf-ord-stck
Open

fix(plugin-ecommerce): sync inventory to latest version with drafts#16525
nehaaprasaad wants to merge 1 commit intopayloadcms:mainfrom
nehaaprasaad:fix/plg-eco-conf-ord-stck

Conversation

@nehaaprasaad
Copy link
Copy Markdown

@nehaaprasaad nehaaprasaad commented May 7, 2026

fix : #16503

What?

  • After confirmOrder, stock was updated on the main product/variant document only.
  • With drafts on, admin / draft: true reads use the latest version row; that row still showed old inventory.

Why?

  • payload.db.updateOne with $inc does not update _…_versions documents, so published “latest” snapshots stayed stale.

How?

  • confirmOrder: after updateOne, if the collection has drafts and the DB is Mongo, call updateVersion with the same inventory $inc and where parent + latest: true.
  • db-mongodb updateVersion: apply the same $inc / $set handling as updateOne so $inc under version.* is a real Mongo update.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: plugin-ecommerce confirmOrder stock $inc leaves _versions stale

1 participant