Skip to content

Commit 30171f3

Browse files
authored
fix(core-flows): add no_notification to fulfillment created event (medusajs#11507)
what: - passes no notification toggle to events - fulfillment created and canceled fixes medusajs#11505
1 parent b60e1c8 commit 30171f3

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts

+19-22
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type CancelOrderFulfillmentValidateOrderStep = {
3838
order: OrderDTO & {
3939
/**
4040
* The order's fulfillments.
41-
*/
41+
*/
4242
fulfillments: FulfillmentDTO[]
4343
}
4444
/**
@@ -48,16 +48,16 @@ export type CancelOrderFulfillmentValidateOrderStep = {
4848
}
4949

5050
/**
51-
* This step validates that an order fulfillment can be canceled. If
51+
* This step validates that an order fulfillment can be canceled. If
5252
* the fulfillment doesn't exist, or it has already been shipped, the step throws an error.
53-
*
53+
*
5454
* :::note
55-
*
55+
*
5656
* You can retrieve an order and fulfillment details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
5757
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
58-
*
58+
*
5959
* :::
60-
*
60+
*
6161
* @example
6262
* const data = cancelOrderFulfillmentValidateOrder({
6363
* order: {
@@ -78,10 +78,7 @@ export type CancelOrderFulfillmentValidateOrderStep = {
7878
*/
7979
export const cancelOrderFulfillmentValidateOrder = createStep(
8080
"cancel-fulfillment-validate-order",
81-
({
82-
order,
83-
input,
84-
}: CancelOrderFulfillmentValidateOrderStep) => {
81+
({ order, input }: CancelOrderFulfillmentValidateOrderStep) => {
8582
throwIfOrderIsCancelled({ order })
8683

8784
const fulfillment = order.fulfillments.find(
@@ -162,17 +159,18 @@ function prepareInventoryUpdate({
162159
/**
163160
* The data to cancel an order's fulfillment, along with custom data that's passed to the workflow's hooks.
164161
*/
165-
export type CancelOrderFulfillmentWorkflowInput = OrderWorkflow.CancelOrderFulfillmentWorkflowInput & AdditionalData
162+
export type CancelOrderFulfillmentWorkflowInput =
163+
OrderWorkflow.CancelOrderFulfillmentWorkflowInput & AdditionalData
166164

167165
export const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"
168166
/**
169167
* This workflow cancels an order's fulfillment. It's used by the [Cancel Order's Fulfillment Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idcancel).
170-
*
171-
* This workflow has a hook that allows you to perform custom actions on the canceled fulfillment. For example, you can pass under `additional_data` custom data that
168+
*
169+
* This workflow has a hook that allows you to perform custom actions on the canceled fulfillment. For example, you can pass under `additional_data` custom data that
172170
* allows you to update custom data models linked to the fulfillment.
173-
*
171+
*
174172
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling a fulfillment.
175-
*
173+
*
176174
* @example
177175
* const { result } = await cancelOrderFulfillmentWorkflow(container)
178176
* .run({
@@ -184,18 +182,16 @@ export const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"
184182
* }
185183
* }
186184
* })
187-
*
185+
*
188186
* @summary
189-
*
187+
*
190188
* Cancel an order's fulfillment.
191-
*
189+
*
192190
* @property hooks.orderFulfillmentCanceled - This hook is executed after the fulfillment is canceled. You can consume this hook to perform custom actions on the canceled fulfillment.
193191
*/
194192
export const cancelOrderFulfillmentWorkflow = createWorkflow(
195193
cancelOrderFulfillmentWorkflowId,
196-
(
197-
input: WorkflowData<CancelOrderFulfillmentWorkflowInput>
198-
) => {
194+
(input: WorkflowData<CancelOrderFulfillmentWorkflowInput>) => {
199195
const order: OrderDTO & { fulfillments: FulfillmentDTO[] } =
200196
useRemoteQueryStep({
201197
entry_point: "orders",
@@ -227,10 +223,11 @@ export const cancelOrderFulfillmentWorkflow = createWorkflow(
227223
prepareInventoryUpdate
228224
)
229225

230-
const eventData = transform({ order, fulfillment }, (data) => {
226+
const eventData = transform({ order, fulfillment, input }, (data) => {
231227
return {
232228
order_id: data.order.id,
233229
fulfillment_id: data.fulfillment.id,
230+
no_notification: data.input.no_notification,
234231
}
235232
})
236233

packages/core/core-flows/src/order/workflows/create-fulfillment.ts

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ export const createOrderFulfillmentWorkflow = createWorkflow(
467467
data: {
468468
order_id: input.order_id,
469469
fulfillment_id: fulfillment.id,
470+
no_notification: input.no_notification,
470471
},
471472
})
472473
)

0 commit comments

Comments
 (0)