Add?db=DatabaseName&cart=[cart]&sku=xx&quantity=xx
To add products to a visitor's shopping cart, click a URL containing the Add command (alternately, you may embed an [AddLineItem] context in a template). Whenever WebCatalog 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):
Try It!
The database "SomeDatabase.db" is opened, and sku 1234 is found. Shopping
Cart file "5678" is opened, and a new line item is added to the bottom
of the list, with a quantity of 5 (as specified in the command above), and a price
taken from the database's price field (or, of 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.
Here are the parameters to the Add command:
| Parameter | Description |
|---|---|
|
db |
Product database that contains the SKU, price, and other information |
|
sku |
Uniquely identifies which product should be added to the cart. |
|
cart |
Shopping cart file that is to be affected |
|
password |
(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 |
|
price |
(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 |
|
textA |
(Optional) Extra information of any kind that you want 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] |
|
textB |
(Optional) Same as textA above |
|
textC |
(Optional) Same as textA above |
|
textD |
(Optional) Same as textA above |
|
textE |
(Optional) Same as textA above |
|
quantity |
|
|
taxable |
(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" |
|
canEmail |
(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" |
|
unitShipCost |
(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. |
| 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. | |
|
RequiredFields |
|