-
-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(core-flows,order,medusa,types): update item metadata on item_update change action #14570
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
base: develop
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@medusajs/core-flows": patch | ||
| "@medusajs/order": patch | ||
| "@medusajs/types": patch | ||
| "@medusajs/medusa": patch | ||
| --- | ||
|
|
||
| feat(core-flows,order,medusa,types): update item metadata on item_update change action |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,11 @@ OrderChangeProcessing.registerActionType(ChangeActionType.ITEM_UPDATE, { | |
| existing.quantity = currentQuantity | ||
| existing.detail.quantity = currentQuantity | ||
|
|
||
| if (action.details.metadata !== undefined) { | ||
NicolasGorga marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| existing.detail.metadata = action.details.metadata | ||
| existing.metadata = action.details.metadata | ||
NicolasGorga marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing null metadata causes runtime TypeError crashHigh Severity The validator accepts |
||
|
|
||
| if (action.details.adjustments) { | ||
| existing.adjustments = action.details.adjustments | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ export function formatOrder<T = any>( | |
| raw_compare_at_unit_price: | ||
| detail.raw_compare_at_unit_price ?? | ||
| orderItem.item.raw_compare_at_unit_price, | ||
| metadata: detail.metadata ?? orderItem.item.metadata, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nullish coalescing prevents clearing metadata to nullMedium Severity The use of |
||
| detail, | ||
| } | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test expects metadata replacement instead of merge behavior
Medium Severity
The test expects metadata to be
{ updated: "metadata", custom_field: "modified" }after updating an item that originally had{ initial: "value", custom_field: "original" }. However, the implementation usesmergeMetadata(per the PR discussion), which preserves existing keys not present in the update. The expected result should be{ initial: "value", custom_field: "modified", updated: "metadata" }to include the preservedinitialkey.Additional Locations (1)
integration-tests/http/__tests__/draft-order/admin/draft-order.spec.ts#L834-L840