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 Aug 29, 2024
1 parent 4e6e81f commit f9195a0
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 @@ -85,6 +86,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 @@ -138,6 +147,8 @@ export const addToCartWorkflow = createWorkflow(
},
})

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

0 comments on commit f9195a0

Please sign in to comment.