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:
Adrien de Peretti
2025-05-11 17:17:19 +02:00
committed by GitHub
parent 47700899ed
commit fff285f8d2
3 changed files with 92 additions and 64 deletions

View File

@@ -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,
},
})
}
)