Shopping Cart Reference

The MX Shopping Cart is a collection of server behaviors used in conjunction with a special data source, the Shopping Cart, which can be added to your site from the Data Binding inspector add menu. When the shopping cart is added to a page, it appears as a data source for the page and is manipulated much like other data sources.

In addition to the default columns in the shopping cart, the shopping cart has three leaf nodes that can be used with other DW MX server behaviors:

[numItems]
sum(Total)
sum(Quantity)

These are similar to the recordset's [first record index], [last record index] and [total records].

The shopping cart needs to be configured to interact with your database or other components. You do this by setting up bindings to the database or other components when you apply the following server behaviors:

Add to cart via form OR Add to cart via link
Save cart to table

A series of interactions with the cart can be set up in the Server Behavior inspector. The following server behaviors are included in the MX Shopping Cart Extension. When you add the shopping cart extension to DW MX, these server behaviors are added to the available behaviors in the Server Behavior inspector. They are found on the Shopping Cart submenu. To use any one of them, you must first add a shopping cart to the page.


Add to cart via form OR Add to cart via link
These two server behaviors are used to add an item to the shopping cart. The "Add to cart via form" behavior is applied to a form button, and the "Add to cart via link" behavior is applied to a text or image link. The parameters are the same for both behaviors.

A form button must be used if you want to add SKU modifiers (such as color and size), as these items must be submitted via a form. If you choose Link for the Link Type, you cannot use SKU modifiers.

You must specify the source for each column that you want to use in the cart. There are five default columns. The Product ID is required. Other columns are optional; the source should be specified as Nothing if you don't want to use them. The default columns cannot be deleted or changed. You may add other columns as desired.

The parameters are shown in the following table.

Parameter Values
Link or Form Element

Name of Link or Form

Binding Type (for each cart column)

None

Literal

Form Element, Form Element Name

Recordset, Recset Column, Unique Key Column

Go to URL

URL or pagename



Cart repeat region
The Cart Repeat Region behavior is similar to the Repeat Region server behavior used with a dynamic table, but you must be sure to use the shopping cart version in this instance. Apply this behavior to the dynamic row in the table, which is bound to the contents of the shopping cart. It has the effect of repeating the row for as many items as the cart contains.

There are no parameters.


Update cart
This is applied to a text field form element (quantity edit box) on a page that contains the shopping cart table display. The text field is bound to the Quantity column in the shopping cart and allows the user to change the quantity of any one item.

To use this behavior, you must also have a form element and a form submit button on the page (appropriately labeled Update Cart or similarly). The shopping cart table display and the form button should be inside the form element tag.

The optional parameter to this behavior is Go to URL. Use this parameter if you want to redirect users to a different page after updating the cart. Otherwise, leave it blank and the page will submit to itself and refresh with the new cart contents.


Empty cart
This is applied to a link on a page that contains the shopping cart table display. The link can be an image or a text link. If no link is selected when the behavior is applied, the default text link "Empty cart" will be created.

The optional parameter to this behavior is Go to URL. Use this parameter if you want to redirect users to a different page after updating the cart. Otherwise, leave it blank and the page will submit to itself and refresh with the new cart contents.


Redirect if empty
This behavior is applied to the shopping cart display page and is used to redirect users to a different page when the contents of the cart is null. The parameters include the link itself and the Go to URL. Use the URL parameter to specify the page to which you want to redirect users when the cart is empty.


Get unique ID from table
This behavior is used to create a unique order ID to use when inserting the order into the database.

To use this behavior, you should create a table in your database with a single numerical field and a single record that contains an initial number. This number is incremented each time the table is accessed. The incremented number is stored in a session variable which is then put in a hidden form element and used to insert the order into the database.

The parameters are shown in the following table.

Parameter Values
Link

Link name

Connection

Connection name

Table

Name of database table for the ID key

Field

Name of field containing the ID key

Session var

Name of session variable



Save cart to table
This behavior is applied to a form button that when clicked submits the contents of the cart to a database.

You must set up the data source into which the contents will be submitted on the page. The data source to which you are submitting must be a view that is updatable in your database schema.

The parameters are shown in the following table.

Parameter Values
Link

Link name

Connection

Connection name

Table

Name of database table into which to insert order

Destination column for cart column

Name of column into which to insert each cart column

Destination column for unique ID

Column into which to insert unique ID value

Go to URL

URL or pagename


To Table of Contents Back to Previous document Forward to next document