Skip to main content

Update an order

Entry. PUT /v1/commerce/orders/:id → OrderCommandService.update.

Checked in order-command.service.ts.

What the transaction enforces​

  • A status change uses isValidOrderTransition unless force is set.
  • If the body includes version and it does not match order.version, the update fails with order.error.concurrencyConflict. A matching version is incremented inside the transaction. A second writer that lost the race gets a conflict.
  • A changed shipping address is rejected while hasActiveShipment is true. The error text says to cancel the shipment first.
  • Moving warehouseId enqueues order.location.changed. See Move warehouse.
  • A transition into CONFIRMED enqueues order.confirmed.

Hold and cancel on the order are status values. What they do to worksheets and reservations is What an order status does to fulfillment. force on the order update skips the order map only.

Delete​

DELETE /v1/commerce/orders/:id calls orderRepository.delete, which runs Prisma delete on the order id. That removes the row. It is not a deletedAt update. The command method does not enqueue an outbox event and does not release reservations. A database foreign key can still reject the delete. That constraint was not listed here.

Failure​

A throw inside the update transaction rolls the order write and the outbox row back together. Downstream fulfillment still runs only after the worker dispatches order.status.changed or order.location.changed.