medusa icon indicating copy to clipboard operation
medusa copied to clipboard

[Bug/Question]: not exposed hooks ?

Open yannickschuchmann opened this issue 6 months ago • 2 comments

Package.json file

-

Node.js version

Database and its version

Operating system name and version

Browser name

No response

What happended?

// completeCartWorkflow
// ...
      createHook("orderCreated", {
        order_id: createdOrder.id,
        cart_id: cart.id,
      })
// ...

I've seen createHook calls like these. What is the purpose of them when they aren't exposed in the end anyway? The completeCartWorkflow exposes a validate hook. So const validate = createHook(.. is at the end of the workflow exposed, e.g.

    return new WorkflowResponse(createdOrder, {
      hooks: [validate], // why not [validate, orderCreated, there are more..] ?
    })

So is there something I don't see or are these createHook calls unused leftovers? If so I'd consider them as bugs because apparently they need to be there but are not usable right now?

I am currently looking for a hook I can use after a order with applied promotions is completed from my store / cart.

Love, Y

Expected behavior

Created hooks should be accessible.

Actual behavior

Created hooks look abandoned.

Link to reproduction repo

yannickschuchmann avatar May 13 '25 10:05 yannickschuchmann

For example. here the hook is exposed in the createOrderWorkflow. For me the inconsistency is not understandable.

https://github.com/medusajs/medusa/blob/da270cd3e25b3067005bc2260a42a298f76436b7/packages/core/core-flows/src/order/workflows/create-order.ts#L267C2-L277C1

yannickschuchmann avatar May 13 '25 12:05 yannickschuchmann

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.

github-actions[bot] avatar Jun 15 '25 02:06 github-actions[bot]

This issue was closed because it has been stalled for 3 days with no activity.

github-actions[bot] avatar Jun 22 '25 02:06 github-actions[bot]