fix(core-flows): support 0 as a valid unit price for custom line items (#11631)

This commit is contained in:
Riqwan Thamir
2025-02-26 19:32:35 +01:00
committed by GitHub
parent d254b2ddba
commit 38beeb157e
3 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
fix(core-flows): support 0 as a valid unit price for custom line items

View File

@@ -756,6 +756,16 @@ medusaIntegrationTestRunner({
},
quantity: 1,
},
{
title: "zero price item",
subtitle: "zero price item",
thumbnail: "some-url",
requires_shipping: false,
is_discountable: false,
is_tax_inclusive: false,
unit_price: 0,
quantity: 1,
},
],
cart_id: cart.id,
},
@@ -841,6 +851,12 @@ medusaIntegrationTestRunner({
variant_sku: null,
variant_title: null,
},
expect.objectContaining({
title: "zero price item",
subtitle: "zero price item",
is_custom_price: true,
unit_price: 0,
}),
],
})
)

View File

@@ -124,7 +124,7 @@ export const addToCartWorkflow = createWorkflow(
isCustomPrice: isDefined(item?.unit_price),
}
if (variant && !input.unitPrice) {
if (variant && !isDefined(input.unitPrice)) {
input.unitPrice = variant.calculated_price?.calculated_amount
}