For developers: Inventory of variations
The inventory of a variation represents its available quantity in the store. You can configure the Ecommerce to track the available quantity and to perform an action after a product variation has depleted. The inventory can be managed through the following properties of the ProductVariation class:
- Inventory
Gets or sets the available quantity for a product variation.
- TrackInventory
Specifies whether the Ecommerce will track the inventory and perform an action after a product variation has depleted. When tracking the inventory of a product variation, the For developers: IEcommerceProductInventoryChanged event is fired every time when the quantity of the product variation changes. The enumeration has the following values:
- DonotTrack
Specifies to not track the inventory for the product.
- Track
Specifies to track the inventory of the product.
- TrackByVariations
Specifies to track the inventories of the product’s variations.
In case of configuring the inventory of a variation, you have to use either the DonotTrack or the TrackByVariations value.
- OutOfStockOption
Specifies the action that should be taken after a product has depleted. The enumeration has the following values:
- DisplayAndAllowOrders
The product will be displayed and further ordering of it will be allowed.
- DisplayButDontAllowOrders
The product will be displayed, but further ordering of it won’t be allowed.
- DoNotDisplayTheProduct
The product won’t be displayed.
Enable tracking by variation for a product
To track the inventory of product’s variations, you have first to enable it on a product level. To do this, modify the product and set its TrackInventory property to TrackInventory.TrackByVariations. For more information about how to modify a product, read For developers: Modify products. Here is a code example:
Enable inventory tracking for a variation
To enable tracking for a variation, you must modify the variation and set its TrackInventory property to TrackInventory.TrackByVariations. For more information about how to modify a variation, read For developers: Modify product variations. Here is a code example:
NOTE: The inventory of the product must be configured to be tracked by variations.
Disable inventory tracking for a variation
To disable tracking for a variation, you must modify the variation and set its TrackInventory property to TrackInventory.DonotTrack. For more information about how to modify a variation, read For developers: Modify product variations. Here is a code example:
Update the inventory of a variation
To available quantity of a variation, you must modify the variation and set its Inventory property to the desired value. For more information about how to modify a variation, read For developers: Modify product variations. Here is a code example: