Create an account to edit articles | See Formatting Syntax for Wiki syntax | We look forward to your contribution!
You are here: The ProductCart Encyclopedia » ProductCart Developers' Corner » pcCartArray: how shopping cart content is stored
pcCartArray: 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, using the syntax:
ProductCart v4
dim pcCartArray(100,45)
ProductCart v3
dim pcCartArray(100,35)
The array holds up to 100 different products and 45 variables for each product (35 variables in v3). 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,45) and redim pcCartArray(100,45) replacing the number “100” with a higher one (change 45 with 35 for v3).
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: " & pcCartArray(f,0) response.write "Product Name: " & pcCartArray(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 | Array of product options - “option groups: options” |
| 5 | Total Cost of all options |
| 6 | Total weight for each product in the cart |
| 7 | Product part number (SKU) |
| 8 | ID of the child within a bundle |
| 9 | Delivery Time. (current not used) |
| 10 | Removed from cart flag. Whether the product has been removed from the shopping cart. |
| 11 | Array of individual selected options ID numbers |
| 12 | Required Accessory |
| 13 | ID of the Supplier of the Product |
| 14 | Product Cost |
| 15 | Discounts |
| 16 | ID of ConfigSession (BTO Only) |
| 17 | Product’s default price (online price). |
| 18 | Whether customer is wholesale or part of a customer category |
| 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 | Array of Individual Options Prices |
| 26 | Array of Options Prices stored as currency |
| 27 | Parent/Bundle Discount |
| 28 | Relationship - Parent Index |
| 29 | BTO Additional Charges Reward Points |
| 30 | Build To Order: Items Discounts |
| 31 | Build To Order: Additional Charges |
| 32 | Apparel Add-on: Stores an array of data. The Parent Product ID is the last element of that array. |
| 33 | IDs of Products in the Gift Registry |
| 34 | Gift wrap flag |
| 35 | Gift wrap message |
| 36 | Surcharge price for first unit of a product (v4 only) |
| 37 | Surcharge price for the additional units of the same product (v4 only) |
| 38 | SubscriptionBridge.com integration's LinkID (v4 only) |
| 39 | ID of the sales that the product is currently part of (v4.5 and above: Sales Manager feature) |
| 40 | Currently not in use (v4 and above) |
| 41 | Currently not in use (v4 and above) |
| 42 | Currently not in use (v4 and above) |
| 43 | Currently not in use (v4 and above) |
| 44 | Currently not in use (v4 and above) |
| 45 | Currently not in use (v4 and above) |
Trace: • ProductCart v4.0 - Service Pack 4 (One Page Checkout Patch) • Installation: finding and uploading the ProductCart files • ProductCart v3.51 Patch Guide • Moving an existing page to ProductCart's Content Management System • Generating a License for a Downloadable Product • Adjust character-set for multilingual store • Adding a login form to your store design • Backing Up Your Store • How We Update a ProductCart-powered Store • pcCartArray: how shopping cart content is stored