Using Inventory Control
Introduction
Please review the database
and basic shopping online tutorial.
This tutorial is an extension of the basic shopping online tutorial
and explains how to implement inventory control with the shopping
basket system.
Without inventory control, customers may purchase any quantity
of any item that you offer for sale. If you prefer to limit purchases
to only available quantities (as listed in your product database),you
may choose to implement inventory controls with your shopping
basket system. Inventory control may only be used with database-driven
shopping baskets.
The database name, product ID field, and inventory field is
stored with each item that is added to a shopping basket. During
the final order processing using mgiSendOrder, the ordered product
quantities are compared with the available quantities in your
product database. If a customer attempts to order a product quantity
that is not available, the customer is redirected to the inventory
error page that is listed in your shopping basket administration.
The specific products that have caused the inventory error are
sent sequentially via path arguments to the inventory error page
where you may present several courses of action including a shopping
basket where the customer can update their order.
MGI Tags
Steps
- Create a product database with an inventory field.
- Open the product result pages in a text editor.
- Insert the inventory parameters in the mgiBuyMe tags.
- Save the product result pages.
- Create an inventory error page.
- Save the inventory error page.
- FTP the product pages and inventory error page to the web
server running MGI.
- View the shopping basket administration page in a web browser.
- Edit and Save the Inventory Options.
- Process an order.
Step 1: Create a product database with an inventory field.
- Inventory control may only be used with a database-driven
shopping basket system. In addition to the product ID, product
name and price, create a field for the current inventory. The
field type must be either Whole Number (Integer) or Positive
Number (Unsigned Integer).
-
- Access the record interface of the database administration.
Enter the current inventory for each product in the inventory
field. Inventory figures can be updated at any time in the database
administration interface.
Step 2: Open the product result pages in a text editor.
- Open the database result pages that contain mgiBuyMe tags
for your products in a text editing program that allows you to
view and modify the HTML and code of the page.
Step 3: Insert the inventory parameters in the mgiBuyMe tags.
- Add the productDB, inventoryFieldName, and productIDFieldName
parameters to all mgiBuyMe tags. In the productDB parameter,
enter the case-sensitive database name that contains the product's
inventory information. In the inventoryFieldName parameter, enter
the case-sensitive database field name that contains the product's
current inventory. In the productIDFieldName parameter, enter
the case-sensitive database field name that contains the product's
unique ID.
-
- The following is an example mgiSearchDatabase tag with inventory
parameters.
<mgiToken>
<form action="shoppingbasket.mgi" method="post">
<h2>Search Results</h2>
<p>
<table width="500" cellspacing="0"
cellpadding="3" border="1">
<tr bgcolor="#eeeeee">
<th>ISBN</th>
<th>Title/Description</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<mgiSearchDatabase databaseName="Products"
keyFieldName="ProductName" fieldValue="*"
orderByField="ProductID" resultsPerPage="5">
<tr>
<td>&mgiDBFieldProductID;</td>
<td><b>&mgiDBFieldProductName;</b>
<p>&mgiDBFieldProductDescription;</td>
<td align="right">$&mgiDBFieldProductPrice;</td>
<td align="center">
<mgiBuyMe productID="&mgiDBFieldProductID;"
name="&mgiDBFieldProductName;"
price="&mgiDBFieldProductPrice;"
productDB="Products" productIDFieldName="ProductID"
inventoryFieldName="Inventory"></td>
</tr>
</mgiSearchDatabase>
<tr>
<td colspan="4" align="right">
<mgiButton value="Add to Shopping Basket"></td>
</tr>
</table>
</p>
</form>
</mgiToken>
Step 4: Save the product result pages.
- Save the changes you have made to the product result pages.
Step 5: Create an inventory error page.
- Create a page to display when an inventory error occurs and
open the page in a text editing program that allows you to view
and modify the HTML and code of the page.
-
- During the shopping basket process, customers add items to
their shopping basket, checkout, confirm their order and finally
submit their order. When a customer submits their order, the
quantity of each item they purchase is compared with the available
quantity as it appears in the inventory field of the specified
database.
-
- If the quantity ordered for all items is less than the quantity
available, the quantity ordered is debited from the quantity
available in the specified database and the order is processed.
-
- If the quantity ordered for any item is greater than the
quantity available, the customer is redirected to the error URL
specified in the Inventory Options of the the shopping basket
admin (see steps 8 and 9 for more information about the Inventory
Options). The error URL is appended with sequential product IDs,
quantities ordered and quantities available path arguments for
each item with an inventory error.
-
- You can use the mgiPathArgument tag and mgiLoop tag to display
the product ID, quantity ordered and quantity available for each
item with an inventory error on the error page. You can also
offer the customer options for correcting the inventory error
such as a shopping basket tag which allows them to update their
quantities. If you offer a shopping basket for modifications,
the inventory error page should be on your non-secure server.
-
- The following is an example inventory error page.
<mgiToken>
<font size="+2">Inventory Errors</font>
<p>The following items in your purchase are not
currently available in the quantity ordered.
Please update the quantity in the shopping basket
below and re-submit your order.
<p>
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th>Product ID</th>
<th>Quantity Ordered</th>
<th>Quantity In Stock</th>
</tr>
<mgiloop first="1" last="10">
<mgiif
lhs={mgipathargument name="productID&mgiLoopIndex;"}
relationship="isnotempty">
<tr>
<td>
<mgipathargument name="productID&mgiLoopIndex;">
</td>
<td align="center">
<mgipathargument name="quantity&mgiLoopIndex;">
</td>
<td align="center">
<mgipathargument name="inventory&mgiLoopIndex;">
</td>
</tr>
</mgiif>
</mgiloop>
</table>
<form action="shoppingbasket.mgi" method="post">
<p><mgiShoppingBasket handle="Default">
</mgiShoppingBasket>
<p><mgiButton value="Modify Quantity">
</form>
<form action="checkout.mgi" method="post">
<mgiButton value="Check Out">
</form>
</mgiToken>
Step 6: Save the inventory error page.
- Save the inventory error page and name it "inverror.mgi".
Step 7: FTP the product pages and inventory error page to
the web server running MGI.
- Upload the product pages and inventory error page (inverror.mgi)
from your local computer to the web server using an FTP program.
Step 8: View the shopping basket administration page in a
web browser.
- View the shopping basket administration page (e.g., sbadmin.mgi)
in a web browser. The first screen of the web-based, administration
interface displays the current shopping basket configurations
(handles)
Step 9: Edit and Save the Inventory Options.
- Click the "Edit" button beside the shopping basket
configuration (handle) to edit.
- Click the "Edit" button beside "Inventory
Options".
- Beside "Perform Inventory" click the "Yes"
radio button. Beside the "Inventory Error URL" enter
the full absolute URL to the inventory error page (e.g., inverror.mgi).
-
- Click the "Save" button to save the changes to
the shopping basket configuration. The main menu displays after
the configuration is saved.
Step 10: Process an order.
- Process an order from your shopping basket. If the quantity
ordered for all products is less than the quantity available,
the quantity ordered is debited from the quantity available and
the order is processed. If the quantity ordered for any product
is greater than the quantity available, you are redirected to
the inventory error page.
|