Skip to content

feat: model purchaseOrderNumber on carts - #422

Merged
korsvanloon merged 1 commit into
mainfrom
feat/cart-purchase-order-number
Aug 27, 2026
Merged

feat: model purchaseOrderNumber on carts#422
korsvanloon merged 1 commit into
mainfrom
feat/cart-purchase-order-number

Conversation

@korsvanloon

Copy link
Copy Markdown
Collaborator

Fixes #411.

Three small pieces:

  1. CartDraft.purchaseOrderNumber is stored on create — it was dropped, so a cart created with one read back without it.
  2. setPurchaseOrderNumber is implemented on CartUpdateHandler; omitting purchaseOrderNumber unsets it, matching the action's optional field.
  3. An order created from a cart carries the cart's purchaseOrderNumber. That is the point of capturing it on the cart, and createFromCart was not copying it.

CartSetPurchaseOrderNumberAction exists only on the full and associate-scoped cart endpoints. The associate scope shares CartRepository, so it needs no separate handler; /me carts share it too, so the action is reachable there as well even though MyCartSetPurchaseOrderNumberAction does not exist — the mock does not filter actions per scope for any resource today, so this PR does not introduce that.

Coverage

cart.test.ts: set then unset the number, and a draft-created cart whose number survives into the order created from it.

Full suite: 792 passing.

@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0923e86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@labdigital/commercetools-mock Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

A cart's purchaseOrderNumber could not be exercised at all: the draft field was
dropped on create and setPurchaseOrderNumber was not implemented, even though
the equivalent has been on orders all along. B2B checkout captures the buyer's
purchase order number on the cart before the order exists, so the round trip had
no coverage available.

The order created from a cart now carries the cart's purchaseOrderNumber, which
is the point of capturing it there.

CartSetPurchaseOrderNumberAction exists only on the full and associate-scoped
cart endpoints, and those share this repository with /me carts; no separate
handler is needed for the associate scope.

Fixes #411
@korsvanloon
korsvanloon force-pushed the feat/cart-purchase-order-number branch from e949307 to 0923e86 Compare August 27, 2026 14:10
@korsvanloon
korsvanloon merged commit 3926536 into main Aug 27, 2026
10 checks passed
@korsvanloon
korsvanloon deleted the feat/cart-purchase-order-number branch August 27, 2026 14:13
@github-actions github-actions Bot mentioned this pull request Aug 27, 2026
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.

Cart: setPurchaseOrderNumber action and CartDraft.purchaseOrderNumber are not modelled

2 participants