feat(core-flows,medusa): adds inventory kit creation to variants endpoint (#7599)
what: When creating a variant, we can now create inventory as a part of the product and variants create endpoint. This applies only to variants where `manage_inventory=true`. 2 cases present itself: 1. When inventory_items are present - Link an inventory item with required_quantity to the variant - the inventory item already needs to be present 2. When inventory_items are not present - A default inventory item will be created - links the created item to the variant with a default required_quantity RESOLVES CORE-2220
This commit is contained in:
@@ -87,8 +87,8 @@ export const wrapVariantsWithInventoryQuantity = async (
|
||||
|
||||
for (const link of links) {
|
||||
const requiredQuantity = link.required_quantity
|
||||
const availableQuantity = (link.inventory.location_levels || []).reduce(
|
||||
(sum, level) => sum + level.available_quantity || 0,
|
||||
const availableQuantity = (link.inventory?.location_levels || []).reduce(
|
||||
(sum, level) => sum + (level?.available_quantity || 0),
|
||||
0
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user