Inventory Objects

Inventory management in Commerce Server sites usually occurs in two stages in the Order Processing pipelines (OPP).

The first stage, the Inventory stage, is usually configured to include components that determine whether a sufficient number of items are available to fill the order for a given product.

The second stage, the Accept stage, may be configured to modify the product table for a site to reflect the new number of items available for a given product. Optionally, you can use the SQLItemADO component in either the Inventory or Accept stages to reduce the local inventory once the items have been purchased.

This section explains how to use the inventory components included in Commerce Server 2000, and explains how you can use Commerce Server to address issues that arise in the context of inventory control.

Inventory and Backordering

Reducing Inventory

Inventory and Backordering

How you manage inventory in your site depends largely on how you want to respond to a situation in which a given item is out of stock. In such a situation you can either place the item on backorder, or you can notify the customer that the item is not currently available.

The FlagInventory and LocalInventory components, which have an affinity with the Inventory stage, coordinate with the Product Info stage to support either response.

Flag Inventory Checking

The FlagInventory component is designed to identify items in the items SimpleList object that are out of stock. When this component runs, it iterates through the items in the items SimpleList object to verify that the _product_in_stock name/value pair for a given item is not zero (0).

If the _product_in_stock name/value pair evaluates to zero (0), the FlagInventory component can respond in one of two ways. The component supports a Disallow Backorder property, which you set using the property page for the component. If the Disallow Backorder check box is selected, and evaluates to zero (0), the FlagInventory component adds a _pur_out_of_stock message to the _Purchase_ErrorsSimpleList object. If the Disallow Backorder component is not selected, and _product_in_stock evaluates to zero (0), then the _inventory_backorder name/value pair for the affected item is set to zero (0).

Ee796501.note(en-US,CS.10).gif Note

  • The FlagInventory component requires that each line item specify _product_in_stock.

Quantity-Based Inventory Checking

The LocalInventory component compares the number of units in the Quantity name/value pair to the number in the _product_local_inventory name/value pair. The _product_local_inventory name/value pair should represent the actual number of items in stock. If the Quantity name/value pair exceeds _product_local_inventory, the difference between these two numbers is written to the _inventory_backorder name/value pair, provided that the LocalInventory component is configured to allow backordering. Otherwise, the LocalInventory component, like the FlagInventory component, writes a _pur_out_of_stock message to the _Purchase_ErrorsSimpleList object.

The LocalInventory component should be added to the basket pipeline to check item availability when the product is added to the basket. If you include the LocalInventory component in the pipeline for your site, the script that you use to display the basket to your users should be written to notify them that a requested item is either out of stock or on backorder.

Ee796501.note(en-US,CS.10).gif Note

  • The LocalInventory component requires that each line item specify product_local_inventory.

Reducing Inventory

The FlagInventory and LocalInventory components are strictly informational components. This means that while they provide notification that a given item is out of stock, they assume that _product_local_inventory for the line item has been maintained by some other process. The SQLItemADO pipeline component can be used for executing a SQL query that updates the product inventory.

Ee796501.note(en-US,CS.10).gif Note

  • You must unpackage a site before starting the following procedure.

To update your inventory using the SQLItemADO pipeline component

  1. Click Start, point to Programs, point to Microsoft Commerce Server 2000, and then click Pipeline Editor.

  2. In the Pipeline Editor, browse to the location of the file total.pcf (for example, <drive:>\Inetpub\wwwroot\<site name>\pipeline), and then double-click the file.

    The total.pcf pipeline appears.

  3. On the pipline, select the Inventory stage, and then on the Edit menu, point to Insert Component, and then click After.

  4. On the Choose a component dialog box, do the following:

    Use this To do this
    Stages Select All.
    Components Select SQLItemADO.
  5. Click OK. The SQLItemADO component appears as a valve on the pipeline.

  6. Double click the SQLItemADO component.

  7. In the Component Properties dialog box, on the SQL Item (ADO) tab, do the following:

    Use this To do this
    Connection String Type an OLEDB connection string to the table storing the inventory data.
    Query Type the SQL query that will update the inventory in the database. The syntax required to replace values in the SQL query is:

    :<position>

    This will replace the items in the SQL query with items listed in the Parameter List box. For example, if you had to replace two values in a SQL query, the format would be:

    SELECT * FROM:1 WHERE Param2=':2'

    Parameter List Type the list of values you want to use in the SQL query that will be evaluated at run time. The Parameter List box uses a special format for replacement. To retrieve data from the order form, use the notation item.<orderformvalue>. For example, to retrieve the quantity of the items ordered from the order form, you would use item.quantity.

    Click OK.

  8. To save your changes, on the File menu, click Save.

Special Considerations for Inventory

You may have a situation in which two customers want an item of which there is only one in stock. As the OrderForm object for each customer passes through the Plan pipeline, the inventory components indicate to both customers that the product is in stock. This is correct behavior, because the number that indicates how many items of a given SKU are in stock has not yet been reduced to zero (0) by an Accept stage component.

However, when the first customer runs through the Purchase pipeline, the SQLItemADO component will reduce the in-stock value to zero (0). When the second customer runs through the Purchase pipeline, the SQLItemADO component will reduce this value to a negative integer. This scenario creates a backorder, even if the Plan pipeline for the site is configured to not allow back ordering.

There are several ways to address this problem.

One solution is to include at the beginning of the Accept stage a SQLItemADO component that checks to ensure that the number of items in stock for a given SKU is larger than zero (0). If no items for a given SKU are in stock, the SQLItemADO component can place the items on backorder (by initializing the _inventory_backorder name/value pair) or can raise the _pur_out_of_stock error.

A second solution is to include an instance of the appropriate inventory component, FlagInventory for example, in both the Inventory stage (Plan pipeline) and in the Accept stage (Purchase pipeline). Following this component, you would include the SQLItemADO component. The inventory component would execute the query to decrement the in-stock value for the item.


All rights reserved.