Adds a product to the specified shopping cart.

To add products to a visitor's shopping cart, click a URL containing the Add command (alternately, you may embed an [AddLineItem] context into a template). Whenever WebDNA receives an Add command, it opens the shopping cart file (creating a new one if necessary) and adds the product (identified by its SKU) to the end of the LineItems in the shopping cart. The item's price, taxable, canEmail, and unitShipCost information is found by looking for the values of those fields in the product database. You can use a different price by creating a Formulas.db database. Also see Remove, Clear, ShowCart, and Purchase.

Example (normally you would link to a URL or form containing the following information):

The database "SomeDatabase.db" opens, and sku 1234 is found. Shopping Cart file "5678" opens, and a new line item is added to the bottom of the list. The item's quantity is 5 (as specified in the command above), and the price is taken from the database's price field (or, if a formula for [price] is available in Formulas.db, the price is calculated using that formula). The page sent back to the browser will be xx.tpl, which typically contains a [LineItems] loop to display the current items in the cart.

Note: normally all database filepaths are relative to the local template. If they begin with "/" they are relative to the web server's virtual host root. As of version 3.0, you may optionally put a "^" in front of the filepath to indicate the file can be found in a global root folder called "Globals" inside the WebCatalogEngine folder. This global root folder is the same regardless of the virtual host.

Note: you may add a maximum of 100 lineitems to a shopping cart.

Here are the parameters to the Add command:
Parameter Description


Product database that contains the SKU, price, and other information


Uniquely identifies which product should be added to the cart.


Shopping cart file that is to be affected


(Optional) In order to change the price (see below) you must provide the lineitem change password, which can be set in the preferences.
Optional Parameters Description


(Optional) Sometimes you may need to change the price of a product while adding it to the cart. Normally you use a formula to vary pricing, but sometimes this alternate technique is preferred. Remember to put the lineitem change password (see above) into the parameters. There is a security risk when using this technique, because outsiders can change the price to anything they like.


(Optional) This is extra information of any kind associated with this line item. Often used to store extra product information, such as "shoe size" or "color." Also used to pass catalog database fields such as [title] through to the order file so they may be viewed later without needing the original database to look for the value of [title].


(Optional) Same as textA above.


(Optional) Same as textA above.


(Optional) Same as textA above.


(Optional) Same as textA above.


(Optional) Tells how many of this SKU should be added to the cart. This quantity is used when calculating subtotals, unitShipCost, etc.


(Optional) "T" or "F". Overrides "taxable" field in the database - normally the information about the item's taxable status is taken from a field called "taxable."


(Optional) "T" or "F". Overrides "canEmail" field in the database - normally the information about the item's canEmail (electronically deliverable) status is taken from a field called "canEmail."


(Optional) A number indicating the item's price for shipping. Overrides "unitShipCost" field in the database - normally the information about the item's unitShipCost status is taken from a field called "unitShipCost". ShipTotal and GrandTotal use this number (multiplied by quantity) to determine the total shipping and grand total.

Header Field

You may set any shopping cart header field (such as Name, taxRate, Address1, etc.) at the same time you add a product to the cart.


You may force the visitor to enter something into a field by using the RequiredFields parameter in the URL. Setting RequiredFields=field1+field2+field3 will display an error message if the visitor forgets to enter text into any of those 3 fields. RequiredFields works for all commands, not just this one.