Technical notes on how shopping cart content is stored

Overview

When products are added to the shopping cart, ProductCart holds the information into an array called pcCartArray. The array is first created when a ProductCart session is started (see Appendix M), using the syntax:

dim pcCartArray(100,35)

The array holds up to 100 different products and 35 variables for each product. This means that ProductCart has a structural limitation to allowing for 100 different products added to the shopping cart at any given time. The limitation is meant to limit the amount of server resources reserved for the task. This is typically never a problem as customers don't normally add 100 different items to the shopping cart.

However, if you need to allow your customers to add more than 100 different individual products, you can do so by performing a global “find & replace” on the strings dim pcCartArray(100,35) and redim pcCartArray(100,35) replacing the number “100” with a higher one.

Looping through the shopping cart array

To keep track of the number of products (indexes) there exist in the cart array, we store a value that in the following session variable: session(“pcCartIndex”)

Each time a customer adds a new product to the shopping cart, the product and all of its attributes such as units purchased, product options, price, discounts, etc. are added to the cart array (you can find a list of properties and corresponding location in the array below). As the product is added to the cart, the “cart index” is incremented by 1 unit.

So if a customer added two products to the cart, the following would be true:

session("pcCartIndex") = 2

The index count (product count) is kept in a session variable so that ProductCart knows how many indexes exist in the shopping cart array. This makes it easy to loop through and use the contents of the array. For example, you could easily loop through and extract the Product ID and Product Name, as shown below:

 ppcCartIndex =session(“pcCartIndex”)
 for f=1 to ppcCartIndex					
  response.write "Product ID: " & ppcCartIndex (f,0)
  response.write "Product Name: " & ppcCartIndex (f,1)
 Next

List of Cart Array Assignments

If you are customizing ProductCart, you may need to store additional product variables in the cart array and/or retrieve existing variables. The following table provides details on what each element of the array stores.

Item Content
0 ID of the product. Uniquely identifies the product.
1 Product name
2 Quantity being purchased
3 Product price
4 Name of Option A
5 Option price
6 Total weight for the product
7 Product part number (SKU)
8 Name of Option B
9 Delivery Time.
10 Removed. Whether the product has been removed from the shopping cart.
11 Option A identifier
12 Option B identifier
13 Product supplier. This is currently not in use.
14 Product cost. This is currently not in use.
15 Discounts.
16 XX
17 Product’s default price (online price).
18 Type of customer (retail vs. wholesale).
19 Whether the product is tax-exempt.
20 Whether the product has free/no shipping.
21 Custom input field data.
22 Reward Points
23 Whether the product is oversized.
24 Tax product array (when more then one tax is used)
25 Option A price
26 Option A price with Currency Sign
27 Option B price
28 Option B price with Currency Sign
29 Not currently in use
30 Build To Order: Items Discounts
31 Build To Order: Additional Charges

Personal Tools