API Availability Calculation
This topic describes how the following APIs calculate >availability. There are some release-specific considerations for updating stock levels.
isOrderable()
Simple product
Returns true if
- product is online, product has no record and default availability = true or
- product is online, product has record and is perpetual or
- product is online, product has record and isn't perpetual and ATS is greater than or equal to the product.minOrderQuantity
Product bundle
Returns true if
- all bundled products are orderable and
- bundle is online, bundle has no record or
- bundle is online, bundle has record and is perpetual or
- bundle is online, bundle has record and isn't perpetual and ATS is greater than or equal to the bundle.minOrderQuantity
Base product
Returns true if all of the following conditions are true:
- base product is online
- at least one variation product is orderable
Product set
Returns true if all of the following conditions are true:
- product set is online
- at least one set product is orderable
isOrderable(Quantity)
Identical to isOrderable(), except that the quantity must be greater than or equal to the specified quantity.
Product bundle
Identical to isOrderable(), except that the quantity must be greater than or equal to the specified quantity.
Base product
Identical to isOrderable(), except that the sum of orderable variation products must be greater than or equal to the quantity.
Product set
Identical to isOrderable(), except that the sum of orderable products in the set must be greater than or equal to the quantity.
isInStock()
Simple product
Returns true if
- product has no record and default in-stock is true or
- product has record and is perpetual or
- product has record and isn't perpetual and stock-level is greater than or equal to the product.minOrderQuantity.
Product bundle
Returns true if
- all bundled products are in-stock and
- bundle has no record or
- bundle has record and is perpetual or
- bundle has record and isn't perpetual and stock-level is greater than or equal to the bundle.minOrderQuantity
Base product
Returns true if
- at least one variation product is in-stock
Product set
Returns true if
- at least one set product is in-stock
isInStock(Quantity)
As above, but stock-level must be greater than or equal to the quantity, and the quantity must be greater than or equal to one.
Product bundle
As above, but stock-level must be greater than or equal to the quantity, and the quantity must be greater than or equal to one.
Base product
As above, but sum of variation product stock-levels must be greater than or equal to the quantity, and the quantity must be greater than or equal to one.
Product set
As above, but sum of set product stock-levels must be greater than or equal to the quantity, and the quantity must be greater than or equal to one.
GetAvailabilityStatus()
Simple product
Returns availability status for quantity one. Possible statuses are:
- IN_STOCK - returned if product is in stock
- BACKORDER - returned if product isn't in stock, but back-orderable, and at least one back-orderable item is left.
- PREORDER - returned if product isn't in stock, but pre-orderable, and at least one pre-orderable item is left
- NOT_AVAILABLE - returned if product is not IN_STOCK, nor BACKORDER, nor PREORDER
Product bundle
Returns availability status for quantity one. See "Simple Product" column for possible statuses.
Returned status is computed based on the records of the bundled products and the record of the bundle if it exists, and represents the lowest availability status of the involved products.
For example, if all bundled products are IN_STOCK, but the bundle has a record and is NOT_AVAILABLE, method returns NOT_AVAILABLE.
Base product
Returns availability status for the variation product with the best availability for quantity one. For example, if all variation products are BACKORDER, but only one is IN_STOCK, method returns IN_STOCK.
Product set
Returns availability status for the set product with the best availability.
GetAvailabilityLevels(Quantity)
Simple product
Returns availability statuses for quantity. For example, if requested quantity is 10, and stock level is two, and product can be backordered, and backorder quantity is five, the method returns the following: IN_STOCK-2, BACKORDER-5, NOT_AVAILABLE-3
Product bundle
Returns availability statuses for quantity. Based on the rules described previously, but computation combines the availability levels of all bundled products and the bundle itself (if it has a record).
Base product
Returns availability status for quantity based on the variation products with the best availability.
Product set
Returns availability statuses for quantity based on the set products with the best availability
ReserveInventoryForOrder(Basket)
Simple product
Decrement product stock-level. Fails if ATS is less than the productLineItem.quantity.
Product bundle
If bundle has record, decrement stock-level of bundle. Decrement stock-levels of bundled product line items recursively. Fails if the available to sell (ATS) value is less than the productLineItem.quantity.
Base product
Fails if product line item is base product. A base product can't be ordered.
Product set
Fails if product line item is product set. A product set can't be ordered.
GetAvailability()
Uses the preorder/backorder allocation and the inventory list default-in-stock flag to calculate availability.