From 3071d09a03205597158afe79d55dd43643a97026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Wed, 21 May 2025 15:37:43 +0200 Subject: [PATCH] fix(core-flows): skip location check if inventory is not managed (#12540) * fix: skip location check if inventory is not managed * fix: rm todo * chore: changeset --- .changeset/tough-bats-walk.md | 5 +++++ .../prepare-confirm-inventory-input.spec.ts | 20 +------------------ .../utils/prepare-confirm-inventory-input.ts | 1 + 3 files changed, 7 insertions(+), 19 deletions(-) create mode 100644 .changeset/tough-bats-walk.md diff --git a/.changeset/tough-bats-walk.md b/.changeset/tough-bats-walk.md new file mode 100644 index 0000000000..0040c43acf --- /dev/null +++ b/.changeset/tough-bats-walk.md @@ -0,0 +1,5 @@ +--- +"@medusajs/core-flows": patch +--- + +fix(core-flows): skip location check if variant is not managed when preparing inventory confirm diff --git a/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts b/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts index 3180685719..67d40e8f41 100644 --- a/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts +++ b/packages/core/core-flows/src/cart/utils/__tests__/prepare-confirm-inventory-input.spec.ts @@ -92,25 +92,7 @@ describe("prepareConfirmInventoryInput", () => { { id: "pv_2", manage_inventory: false, - inventory_items: [ - { - inventory_item_id: "ii_2", - variant_id: "pv_2", - required_quantity: 1, - inventory: [ - { - location_levels: { - stock_locations: [ - { - id: "sl_1", - sales_channels: [{ id: "sc_1" }], - }, - ], - }, - }, - ], - }, - ], + inventory_items: [], // not managed variant doesn't have inventory }, ], items: [ diff --git a/packages/core/core-flows/src/cart/utils/prepare-confirm-inventory-input.ts b/packages/core/core-flows/src/cart/utils/prepare-confirm-inventory-input.ts index 31e392e922..a4c76bb522 100644 --- a/packages/core/core-flows/src/cart/utils/prepare-confirm-inventory-input.ts +++ b/packages/core/core-flows/src/cart/utils/prepare-confirm-inventory-input.ts @@ -151,6 +151,7 @@ export const prepareConfirmInventoryInput = (data: { if (salesChannelId) { for (const variant of allVariants.values()) { if ( + variant.manage_inventory && !variantsWithLocationForChannel.has(variant.id) && !variant.allow_backorder ) {