Store order details in database

The Checkout Wizard configures the Store Cart Details in Database server behavior to insert a new record in a database table for each line item detail specific to the order.

Databases typically use two tables to handle orders, a general Orders table and an OrderDetails table. The two tables are linked by key field, usually OrderID; each record in the OrderDetails table includes a column called something like DetailsOrderID that corresponds to the OrderID column in the Orders table.

This makes it possible to retrieve a summary of all the orders placed by a particular customer by querying just the Orders table or to get a listing of all the products on a particular order by querying the OrderDetails page.

You can also employ a database view (also called a query of a query) that combines information from the two tables.

The Store Cart Details in Database server behavior adds records to the OrdersDetails table. This server behavior is used together with the Store Cart Summary in Database server behavior configured in the previous step to save all the cart information at the same time.

To configure storing the order details:

  1. Choose a table to insert the shopping cart information into from the Table list.

    The table chosen should have, at a minimum, columns for a details order ID (the unique key field), an order ID, an item ID, and quantity. Other useful columns include ones for a product name, price and selected options.
  2. Select the filed that contains the unique key for the order summary record in the pervious step. This is how the line items can all be related back to the main details of the order.
  3. Bind values to the table columns listed in the columns area. Either static or dynamic values can be used.

    To bind a static value, enter it in the Value field for a selected column.

    To bind a dynamic value, choose the lightning bolt to open the Dynamic Data dialog box and select an item from a shopping cart entry; click OK to close the Dynamic Data dialog.

    Dynamic values can also be entered by hand in the Value field.

    In the example figure, the following values are assigned:
    • DetailsID - Left blank and not updated. DetailsID is an autonumber field.
    • DetailOrderID - Expand the Session entry in the Dynamic Data dialog and select OrderNumber. The OrderNumber session variable is defined in the Save Cart Summary in Database server behavior.
    • DetailProductID - The ID column from the shopping cart dynamic data entry is selected.
    • DetailProductName - The Name column from the shopping cart dynamic data entry is selected.
    • DetailQuantity - The Quantity column from the shopping cart dynamic data entry is selected.
    • DetailPrice - The Price column from the shopping cart dynamic data entry is selected.
    • DetailOption1, DetailOption2 - No options are specified for this example, so these entries are left blank. For an entry to be left blank, the associated column in the database table must be able to accept zero length (null) values.
  4. Click Next when you're done to proceed through the wizard.
You can modify this configuration after the Checkout Wizard has been completed by accessing the Store Cart Details in Database server behavior through the Server Behaviors panel. As well, you can also apply this server behavior outside of the Checkout Wizard specific to your own needs, or to apply more advanced configuration options not immediately available in the Checkout Wizard. See Store Cart Details in Database server behavior for more information.