addToShoppingCart.asp Module Code

The addToShoppingCart.asp module adds a product to the shopping cart by adding a row to arrays held in session variables.

Adding a Row to Session Variable Arrays

  1. Assign the session variables to temporary variables:
    aiSKProductIDs        = session("aiSKProductIDs")    
    aiSKCategoryIDs        = session("aiSKCategoryIDs")        
    aiSKProductQuantitys    = session("aiSKProductQuantitys")    
    aiSKProductPrices        = session("aiSKProductPrices")    
    acSKProductNames        = session("acSKProductNames")    
    acSKProductDescriptions    = session("acSKProductDescriptions")
    
  2. Increase row counter and redimension the temporary variables:
    jCount = CInt(iCartCount + 1)redim preserve aiSKProductIDs(jCount)        redim preserve aiSKCategoryIDs(jCount)        redim preserve aiSKProductQuantitys(jCount)    redim preserve aiSKProductPrices(jCount)    
    redim preserve acSKProductNames(jCount)    
    redim preserve acSKProductDescriptions(jCount)
    
  3. Add values to new row:
    aiSKProductIDs(iCartCount)            = request("iProductID")
    aiSKCategoryIDs(iCartCount)        = request("iCategoryID")
    aiSKProductQuantitys(iCartCount)        = htmlQuantity
    aiSKProductPrices(iCartCount)        = request("iProductPrice")
    acSKProductNames(iCartCount)        = request("cProductName")
    acSKProductDescriptions(iCartCount)    = request("cProductDescription")
    
  4. Assign the temporary variables to the session variable arrays:
    session("aiSKProductIDs")            = aiSKProductIDs        
    session("aiSKCategoryIDs")            = aiSKCategoryIDs        
    session("aiSKProductQuantitys")        = aiSKProductQuantitys        
    session("aiSKProductPrices")        = aiSKProductPrices        
    session("acSKProductNames")        = acSKProductNames        
    session("acSKProductDescriptions")    = acSKProductDescriptions