Skip to main content

Class: InventoryService

Hierarchy

  • "medusa-interfaces"

    InventoryService

Constructors

constructor

new InventoryService(__namedParameters)

Parameters

NameType
__namedParametersObject

Overrides

BaseService.constructor

Defined in

services/inventory.js:5

Methods

adjustInventory

adjustInventory(variantId, adjustment): Promise<any>

Updates the inventory of a variant based on a given adjustment.

Parameters

NameTypeDescription
variantIdstringthe id of the variant to update
adjustmentnumberthe number to adjust the inventory quantity by

Returns

Promise<any>

resolves to the update result.

Defined in

services/inventory.js:36


confirmInventory

confirmInventory(variantId, quantity): Promise<boolean>

Checks if the inventory of a variant can cover a given quantity. Will return true if the variant doesn't have managed inventory or if the variant allows backorders or if the inventory quantity is greater than quantity.

Parameters

NameTypeDescription
variantIdstringthe id of the variant to check
quantitynumberthe number of units to check availability for

Returns

Promise<boolean>

true if the inventory covers the quantity

Defined in

services/inventory.js:62


withTransaction

withTransaction(transactionManager): InventoryService

Parameters

NameType
transactionManagerany

Returns

InventoryService

Defined in

services/inventory.js:15