fix(): Cart workflow price calculation for different items but same variant (#13511)

RESOLVES CORE-1204

**What**
- Fix wrong price tier when multiple items are targetting the same variant
- fix type import from the wrong package

**Notes**
If you are struggling navigating the changes, you can focus on the following files:
```
integration-tests/http/__tests__/cart/store/cart.spec.ts
integration-tests/modules/__tests__/cart/store/cart.workflows.spec.ts
packages/core/core-flows/src/cart/steps/get-promotion-codes-to-apply.ts
packages/core/core-flows/src/cart/steps/get-variant-price-sets.ts
packages/core/core-flows/src/cart/workflows/add-to-cart.ts
packages/core/core-flows/src/cart/workflows/create-carts.ts
packages/core/core-flows/src/cart/workflows/get-variants-and-items-with-prices.ts
packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts
packages/core/core-flows/src/order/workflows/add-line-items.ts
packages/core/core-flows/src/order/workflows/create-order.ts
```
This commit is contained in:
Adrien de Peretti
2025-09-26 09:19:46 +02:00
committed by GitHub
parent 3960c80e9f
commit 5ea32aaa44
281 changed files with 1864 additions and 1466 deletions

View File

@@ -1881,7 +1881,7 @@ medusaIntegrationTestRunner({
expect(errors).toEqual([
{
action: "get-variant-price-sets",
action: "get-variant-items-with-prices-workflow-as-step",
handlerType: "invoke",
error: expect.objectContaining({
message: expect.stringContaining(
@@ -4307,18 +4307,20 @@ medusaIntegrationTestRunner({
})
}
const { result: result1 } = await listShippingOptionsForCartWorkflow(
appContainer
).run({ input: { cart_id: cart.id } })
const { result: result1 } =
await listShippingOptionsForCartWorkflow(appContainer).run({
input: { cart_id: cart.id },
})
expect(result1).toHaveLength(1)
expect(result1[0].name).toEqual(shippingOption.name)
setShippingOptionsContextHook = undefined
const { result: result2 } = await listShippingOptionsForCartWorkflow(
appContainer
).run({ input: { cart_id: cart.id } })
const { result: result2 } =
await listShippingOptionsForCartWorkflow(appContainer).run({
input: { cart_id: cart.id },
})
expect(result2).toHaveLength(0)
})