feat(medusa, types, utils, core-flows, order) request & accept order transfer (#10106)
**What** - add request order transfer workflow - add admin endpoint for transferring an order to a customer - accept order transfer storefront endpoint - accept transfer workflow - changes in the order module to introduce new change and action types --- **Note** - we return 400 instead 409 currently if there is already an active order edit, I will revisit this in a followup - endpoint for requesting order transfer from the storefront will be added in a separate PR --- RESOLVES CMRC-701 RESOLVES CMRC-703 RESOLVES CMRC-704 RESOLVES CMRC-705
This commit is contained in:
@@ -13,3 +13,4 @@ export * from "./ship-item"
|
||||
export * from "./shipping-add"
|
||||
export * from "./shipping-remove"
|
||||
export * from "./write-off-item"
|
||||
export * from "./transfer-customer"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { ChangeActionType, MedusaError } from "@medusajs/framework/utils"
|
||||
import { OrderChangeProcessing } from "../calculate-order-change"
|
||||
import { setActionReference } from "../set-action-reference"
|
||||
|
||||
OrderChangeProcessing.registerActionType(ChangeActionType.TRANSFER_CUSTOMER, {
|
||||
operation({ action, currentOrder, options }) {
|
||||
currentOrder.customer_id = action.reference_id
|
||||
|
||||
setActionReference(currentOrder, action, options)
|
||||
},
|
||||
validate({ action }) {
|
||||
if (!action.reference_id) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
"Reference to customer ID is required"
|
||||
)
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user