1 ---
2 tags:
3 - inventory
4 - product
5 - stock location
6 - concept
7 products:
8 - product
9 - stock location
10 ---
11
12 export const metadata = {
13 title: `Inventory Kits`,
14 }
15
16 # {metadata.title}
17
18 In this guide, you'll learn how inventory kits can be used in the Medusa application to support use cases like multi-part products, bundled products, and shared inventory across products.
19
20 <Note title="Looking for no-code docs?">
21
22 Refer to the following user guides to learn how to use the Medusa Admin dashboard to:
23
24 - [Create Multi-Part Products](!user-guide!/products/create/multi-part).
25 - [Create Bundled Products](!user-guide!/products/create/bundle).
26
27 </Note>
28
29 ## What is an Inventory Kit?
30
31 An inventory kit is a collection of inventory items that are linked to a single product variant. These inventory items can be used to represent different parts of a product, or to represent a bundle of products.
32
33 The Medusa application links inventory items from the [Inventory Module](../page.mdx) to product variants in the [Product Module](../../product/page.mdx). Each variant can have multiple inventory items, and these inventory items can be re-used or shared across variants.
34
35 Using inventory kits, you can implement use cases like:
36
37 - [Multi-part products](#multi-part-products): A product that consists of multiple parts, each with its own inventory item.
38 - [Bundled products](#bundled-products): A product that is sold as a bundle, where each variant in the bundle product can re-use the inventory items of another product that should be sold as part of the bundle.
39
40 ---
41
42 ## Multi-Part Products
43
44 Consider your store sells bicycles that consist of a frame, wheels, and seats, and you want to manage the inventory of these parts separately.
45
46 To implement this in Medusa, you can:
47
48 - Create inventory items for each of the different parts.
49 - For each bicycle product, add a variant whose inventory kit consists of the inventory items of each of the parts.
50
51 Then, whenever a customer purchases a bicycle, the inventory of each part is updated accordingly. You can also use the `required_quantity` of the variant's inventory items to set how much quantity is consumed of the part's inventory when a bicycle is sold. For example, the bicycle's wheels require 2 wheels inventory items to be sold when a bicycle is sold.
52
53 ![Diagram showcasing how a variant is linked to multi-part inventory items](https://res.cloudinary.com/dza7lstvk/image/upload/v1736414257/Medusa%20Resources/multi-part-product_kepbnx.jpg)
54
55 ### Create Multi-Part Product
56
57 Using the [Medusa Admin](!user-guide!/products/create/multi-part), you can create a multi-part product by creating its inventory items first, then assigning these inventory items to the product's variant(s).
58
59 Using [workflows](!docs!/learn/fundamentals/workflows), you can implement this by first creating the inventory items:
60
61 export const multiPartsHighlights1 = [
62 ["11", "stockLocations", "Retrieve the stock locations to create the inventory items in."],
63 ["19", "inventoryItems", "Create the inventory items."]
64 ]
65
66 ```ts highlights={multiPartsHighlights1}
67 import {
68 createInventoryItemsWorkflow,
69 useQueryGraphStep,
70 } from "@medusajs/medusa/core-flows"
71 import { createWorkflow } from "@medusajs/framework/workflows-sdk"
72
73 export const createMultiPartProductsWorkflow = createWorkflow(
74 "create-multi-part-products",
75 () => {
76 // Alternatively, you can create a stock location
77 const { data: stockLocations } = useQueryGraphStep({
78 entity: "stock_location",
79 fields: ["*"],
80 filters: {
81 name: "European Warehouse",
82 },
83 })
84
85 const inventoryItems = createInventoryItemsWorkflow.runAsStep({
86 input: {
87 items: [
88 {
89 sku: "FRAME",
90 title: "Frame",
91 location_levels: [
92 {
93 stocked_quantity: 100,
94 location_id: stockLocations[0].id,
95 },
96 ],
97 },
98 {
99 sku: "WHEEL",
100 title: "Wheel",
101 location_levels: [
102 {
103 stocked_quantity: 100,
104 location_id: stockLocations[0].id,
105 },
106 ],
107 },
108 {
109 sku: "SEAT",
110 title: "Seat",
111 location_levels: [
112 {
113 stocked_quantity: 100,
114 location_id: stockLocations[0].id,
115 },
116 ],
117 },
118 ],
119 },
120 })
121
122 // TODO create the product
123 }
124 )
125 ```
126
127 You start by retrieving the stock location to create the inventory items in. Alternatively, you can [create a stock location](/references/medusa-workflows/createStockLocationsWorkflow).
128
129 Then, you create the inventory items that the product variant consists of.
130
131 Next, create the product and pass the inventory item's IDs to the product's variant:
132
133 export const multiPartHighlights2 = [
134 ["15", "inventoryItemIds", "Create an array of inventory items to pass to the variant."],
135 ["26", "products", "Create the product with the inventory items."],
136 ["43", "inventoryItemIds", "Pass the inventory item IDs as the product variant's inventory items."]
137 ]
138
139 ```ts highlights={multiPartHighlights2}
140 import {
141 // ...
142 transform,
143 } from "@medusajs/framework/workflows-sdk"
144 import {
145 // ...
146 createProductsWorkflow,
147 } from "@medusajs/medusa/core-flows"
148
149 export const createMultiPartProductsWorkflow = createWorkflow(
150 "create-multi-part-products",
151 () => {
152 // ...
153
154 const inventoryItemIds = transform({
155 inventoryItems,
156 }, (data) => {
157 return data.inventoryItems.map((inventoryItem) => {
158 return {
159 inventory_item_id: inventoryItem.id,
160 // can also specify required_quantity
161 }
162 })
163 })
164
165 const products = createProductsWorkflow.runAsStep({
166 input: {
167 products: [
168 {
169 title: "Bicycle",
170 variants: [
171 {
172 title: "Bicycle - Small",
173 prices: [
174 {
175 amount: 100,
176 currency_code: "usd",
177 },
178 ],
179 options: {
180 "Default Option": "Default Variant",
181 },
182 inventory_items: inventoryItemIds,
183 },
184 ],
185 options: [
186 {
187 title: "Default Option",
188 values: ["Default Variant"],
189 },
190 ],
191 shipping_profile_id: "sp_123",
192 },
193 ],
194 },
195 })
196 }
197 )
198 ```
199
200 You prepare the inventory item IDs to pass to the variant using [transform](!docs!/learn/fundamentals/workflows/variable-manipulation) from the Workflows SDK, then pass these IDs to the created product's variant.
201
202 You can now [execute the workflow](!docs!/learn/fundamentals/workflows#3-execute-the-workflow) in [API routes](!docs!/learn/fundamentals/api-routes), [scheduled jobs](!docs!/learn/fundamentals/scheduled-jobs), or [subscribers](!docs!/learn/fundamentals/events-and-subscribers).
203
204 ---
205
206 ## Bundled Products
207
208 <Note>
209
210 While inventory kits support bundled products, some features like custom pricing for a bundle or separate fulfillment for a bundle's items are not supported. To support those features, follow the [Bundled Products](../../../recipes/bundled-products/examples/standard/page.mdx) tutorial to learn how to customize the Medusa application to add bundled products.
211
212 </Note>
213
214 Consider you have three products: shirt, pants, and shoes. You sell those products separately, but you also want to offer them as a bundle.
215
216 ![Diagram showcasing products each having their own variants and inventory](https://res.cloudinary.com/dza7lstvk/image/upload/v1736414787/Medusa%20Resources/bundled-product-1_vmzewk.jpg)
217
218 You can do that by creating a product, where each variant re-uses the inventory items of each of the shirt, pants, and shoes products.
219
220 Then, when the bundled product's variant is purchased, the inventory quantity of the associated inventory items are updated.
221
222 ![Diagram showcasing a bundled product using the same inventory as the products part of the bundle](https://res.cloudinary.com/dza7lstvk/image/upload/v1736414780/Medusa%20Resources/bundled-product_x94ca1.jpg)
223
224 ### Create Bundled Product
225
226 You can create a bundled product in the [Medusa Admin](!user-guide!/products/create/bundle) by creating the products part of the bundle first, each having its own inventory items. Then, you create the bundled product whose variant(s) have inventory kits composed of inventory items from each of the products part of the bundle.
227
228 Using [workflows](!docs!/learn/fundamentals/workflows), you can implement this by first creating the products part of the bundle:
229
230 export const bundledHighlights1 = [
231 ["11", "products", "Create the products part of the bundle."],
232 ["29", "manage_inventory", "Enabling this without specifying inventory items creates a default inventory item."]
233 ]
234
235 ```ts highlights={bundledHighlights1}
236 import {
237 createWorkflow,
238 } from "@medusajs/framework/workflows-sdk"
239 import {
240 createProductsWorkflow,
241 } from "@medusajs/medusa/core-flows"
242
243 export const createBundledProducts = createWorkflow(
244 "create-bundled-products",
245 () => {
246 const products = createProductsWorkflow.runAsStep({
247 input: {
248 products: [
249 {
250 title: "Shirt",
251 shipping_profile_id: "sp_123",
252 variants: [
253 {
254 title: "Shirt",
255 prices: [
256 {
257 amount: 10,
258 currency_code: "usd",
259 },
260 ],
261 options: {
262 "Default Option": "Default Variant",
263 },
264 manage_inventory: true,
265 },
266 ],
267 options: [
268 {
269 title: "Default Option",
270 values: ["Default Variant"],
271 },
272 ],
273 },
274 {
275 title: "Pants",
276 shipping_profile_id: "sp_123",
277 variants: [
278 {
279 title: "Pants",
280 prices: [
281 {
282 amount: 10,
283 currency_code: "usd",
284 },
285 ],
286 options: {
287 "Default Option": "Default Variant",
288 },
289 manage_inventory: true,
290 },
291 ],
292 options: [
293 {
294 title: "Default Option",
295 values: ["Default Variant"],
296 },
297 ],
298 },
299 {
300 title: "Shoes",
301 shipping_profile_id: "sp_123",
302 variants: [
303 {
304 title: "Shoes",
305 prices: [
306 {
307 amount: 10,
308 currency_code: "usd",
309 },
310 ],
311 options: {
312 "Default Option": "Default Variant",
313 },
314 manage_inventory: true,
315 },
316 ],
317 options: [
318 {
319 title: "Default Option",
320 values: ["Default Variant"],
321 },
322 ],
323 },
324 ],
325 },
326 })
327
328 // TODO re-retrieve with inventory
329 }
330 )
331 ```
332
333 You create three products and enable `manage_inventory` for their variants, which will create a default inventory item. You can also create the inventory item first for more control over the quantity as explained in [the previous section](#create-multi-part-product).
334
335 Next, retrieve the products again but with variant information:
336
337 export const bundledHighlights2 = [
338 ["13", "productIds", "Prepare the product IDs to retrieve them with Query."],
339 ["18", "productsWithInventory", "Re-retrieve the products with the inventory items of the product's variant."],
340 ["29", "inventoryItemIds", "Prepare the inventory items to pass to the bundled product's variant."]
341 ]
342
343 ```ts highlights={bundledHighlights2}
344 import {
345 // ...
346 transform,
347 } from "@medusajs/framework/workflows-sdk"
348 import {
349 useQueryGraphStep,
350 } from "@medusajs/medusa/core-flows"
351
352 export const createBundledProducts = createWorkflow(
353 "create-bundled-products",
354 () => {
355 // ...
356 const productIds = transform({
357 products,
358 }, (data) => data.products.map((product) => product.id))
359
360 // @ts-ignore
361 const { data: productsWithInventory } = useQueryGraphStep({
362 entity: "product",
363 fields: [
364 "variants.*",
365 "variants.inventory_items.*",
366 ],
367 filters: {
368 id: productIds,
369 },
370 })
371
372 const inventoryItemIds = transform({
373 productsWithInventory,
374 }, (data) => {
375 return data.productsWithInventory.map((product) => {
376 return {
377 inventory_item_id: product.variants[0].inventory_items?.[0]?.inventory_item_id,
378 }
379 })
380 })
381
382 // create bundled product
383 }
384 )
385 ```
386
387 Using [Query](!docs!/learn/fundamentals/query), you retrieve the product again with the inventory items of each variant. Then, you prepare the inventory items to pass to the bundled product's variant.
388
389 Finally, create the bundled product:
390
391 export const bundledProductHighlights3 = [
392 ["5", "bundledProduct", "Create the bundled product."],
393 ["23", "inventory_items", "Pass the inventory items of the products part of the bundle."]
394 ]
395
396 ```ts highlights={bundledProductHighlights3}
397 export const createBundledProducts = createWorkflow(
398 "create-bundled-products",
399 () => {
400 // ...
401 const bundledProduct = createProductsWorkflow.runAsStep({
402 input: {
403 products: [
404 {
405 title: "Bundled Clothes",
406 shipping_profile_id: "sp_123",
407 variants: [
408 {
409 title: "Bundle",
410 prices: [
411 {
412 amount: 30,
413 currency_code: "usd",
414 },
415 ],
416 options: {
417 "Default Option": "Default Variant",
418 },
419 inventory_items: inventoryItemIds,
420 },
421 ],
422 options: [
423 {
424 title: "Default Option",
425 values: ["Default Variant"],
426 },
427 ],
428 },
429 ],
430 },
431 }).config({ name: "create-bundled-product" })
432 }
433 )
434 ```
435
436 The bundled product has the same inventory items as those of the products part of the bundle.
437
438 You can now [execute the workflow](!docs!/learn/fundamentals/workflows#3-execute-the-workflow) in [API routes](!docs!/learn/fundamentals/api-routes), [scheduled jobs](!docs!/learn/fundamentals/scheduled-jobs), or [subscribers](!docs!/learn/fundamentals/events-and-subscribers).