Skip to content

Commit

Permalink
feat(addToCartWorkflow): Add beforeAddToCart hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexnortung committed Sep 13, 2024
1 parent 2c8ae60 commit 331da80
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/core-flows/src/cart/workflows/add-to-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import {
WorkflowData,
WorkflowResponse,
createHook,
createWorkflow,
parallelize,
transform,
Expand Down Expand Up @@ -89,6 +90,14 @@ export const addToCartWorkflow = createWorkflow(
items: lineItems,
})

const beforeAddToCart = createHook(
"beforeAddToCart",
{
itemsToCreate,
itemsToUpdate,
}
);

confirmVariantInventoryWorkflow.runAsStep({
input: {
sales_channel_id: input.cart.sales_channel_id as string,
Expand Down Expand Up @@ -142,6 +151,8 @@ export const addToCartWorkflow = createWorkflow(
},
})

return new WorkflowResponse(items)
return new WorkflowResponse(items, {
hooks: [beforeAddToCart],
})
}
)

0 comments on commit 331da80

Please sign in to comment.