feat(core-flows): Emit cart trasnferred customer (#12425)
**What** When a cart is transferred emit an event notifying of the action with the cart id and the customer id
This commit is contained in:
1 parent
47700899ed
commit
fff285f8d2
3 files changed
+29
-1
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/core-flows": patch
|
||||
"@medusajs/utils": patch
|
||||
---
|
||||
|
||||
feat(core-flows): Emit cart trasnferred customer
|
||||
@@ -6,9 +6,10 @@ import {
|
||||
WorkflowData,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { useQueryGraphStep } from "../../common"
|
||||
import { emitEventStep, useQueryGraphStep } from "../../common"
|
||||
import { updateCartsStep } from "../steps"
|
||||
import { refreshCartItemsWorkflow } from "./refresh-cart-items"
|
||||
import { CartWorkflowEvents } from "@medusajs/framework/utils"
|
||||
|
||||
/**
|
||||
* The cart ownership transfer details.
|
||||
@@ -110,6 +111,14 @@ export const transferCartCustomerWorkflow = createWorkflow(
|
||||
refreshCartItemsWorkflow.runAsStep({
|
||||
input: { cart_id: input.id, force_refresh: true },
|
||||
})
|
||||
|
||||
emitEventStep({
|
||||
eventName: CartWorkflowEvents.CUSTOMER_TRANSFERRED,
|
||||
data: {
|
||||
id: input.id,
|
||||
customer_id: customer.customer_id,
|
||||
},
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -48,6 +48,19 @@ export const CartWorkflowEvents = {
|
||||
* ```
|
||||
*/
|
||||
REGION_UPDATED: "cart.region_updated",
|
||||
|
||||
/**
|
||||
* Emitted when the customer in the cart is transferred.
|
||||
*
|
||||
* @eventPayload
|
||||
* ```ts
|
||||
* {
|
||||
* id, // The ID of the cart
|
||||
* customer_id, // The ID of the customer
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
CUSTOMER_TRANSFERRED: "cart.customer_transferred",
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user