fix(promotion, core-flows): updating cart with removed promotion removes adjustments (#10489)

This commit is contained in:
Riqwan Thamir
2024-12-08 13:13:31 +01:00
committed by GitHub
parent 864f53011b
commit f95c4e240c
5 changed files with 62 additions and 76 deletions

View File

@@ -106,13 +106,16 @@ export const refreshCartItemsWorkflow = createWorkflow(
input: { cart_id: cart.id },
})
const cartPromoCodes = transform({ cart, input }, ({ cart, input }) => {
if (isDefined(input.promo_codes)) {
return input.promo_codes
} else {
return cart.promotions.map((p) => p.code)
const cartPromoCodes = transform(
{ refetchedCart, input },
({ refetchedCart, input }) => {
if (isDefined(input.promo_codes)) {
return input.promo_codes
} else {
return refetchedCart.promotions.map((p) => p?.code).filter(Boolean)
}
}
})
)
updateCartPromotionsWorkflow.runAsStep({
input: {