%
Session.LCID = 1030 ' 1030 = dk 1033 = us
cartname = Request("cart")
cartitemadd = Request("add")
cartitemremove = Request("remove")
cartitemquantity = Request("quantity")
cartitemreset = Request("reset")
cartitemshow = Request("show")
cartitemshowall = Request("showall")
cartorder = Request("order")
send = Request("send")
Dim tmpArray()
Dim tmpSize, tmpCol, tmpRow
'------------add-----------
If (cartitemadd <> "") Then
If IsArray(Session("cart")) Then
tmpCol = UBound(Session("cart"),1)
tmpRow = UBound(Session("cart"),2)
Redim tmpArray(tmpCol,tmpRow)
For i = 0 to tmpCol
For j = 0 to tmpRow
tmpArray(i,j) = Session("cart")(i,j)
Next
Next
tmpSize = tmpRow
For tmpCounter = 0 to tmpSize
If ((tmpArray(0,tmpCounter) = cartname) and (tmpArray(1,tmpCounter) = cartitemadd)) Then
If (Cint(cartitemquantity) >= 1) Then
tmpArray(2,tmpCounter) = Cint(tmpArray(2,tmpCounter)) + Cint(cartitemquantity)
done = true
else
tmpArray(2,tmpCounter) = 1
done = true
End If
End If
Next
If (done <> true) Then
tmpSize = tmpSize + 1
Redim Preserve tmpArray(2,tmpSize)
tmpArray(0,tmpSize) = cartname
tmpArray(1,tmpSize) = cartitemadd
If (Cint(cartitemquantity) >= 1) Then
tmpArray(2,tmpSize) = Cint(cartitemquantity)
else
tmpArray(2,tmpSize) = 1
End If
End If
Else
Redim tmpArray(2,0)
tmpArray(0,0) = cartname
tmpArray(1,0) = cartitemadd
If (Cint(cartitemquantity) >= 1) Then
tmpArray(2,0) = Cint(cartitemquantity)
else
tmpArray(2,0) = 1
End If
End If
Session("cart") = tmpArray
If (cartitemshowall = "") Then
cartitemshow = cartitemadd
End If
End If
'------------remove-----------
If (cartitemremove <> "") Then
If IsArray(Session("cart")) Then
tmpCol = UBound(Session("cart"),1)
tmpRow = UBound(Session("cart"),2)
Redim tmpArray(tmpCol,tmpRow)
For i = 0 to tmpCol
For j = 0 to tmpRow
tmpArray(i,j) = Session("cart")(i,j)
Next
Next
tmpSize = tmpRow
For tmpCounter = 0 to tmpSize
If ((tmpArray(0,tmpCounter) = cartname) and (tmpArray(1,tmpCounter) = cartitemremove)) Then
If (Cint(cartitemquantity) >= 1) Then
tmpArray(2,tmpCounter) = Cint(tmpArray(2,tmpCounter)) - Cint(cartitemquantity)
If (Cint(tmpArray(2,tmpCounter)) < 1) Then
tmpSize = tmpSize - 1
For rmLoop = tmpCounter to tmpSize
tmpArray(0,rmLoop) = tmpArray(0,rmLoop+1)
tmpArray(1,rmLoop) = tmpArray(1,rmLoop+1)
tmpArray(2,rmLoop) = tmpArray(2,rmLoop+1)
Next
tmpArray(0,tmpSize+1) = ""
tmpArray(1,tmpSize+1) = ""
tmpArray(2,tmpSize+1) = 0
End If
done = true
else
tmpSize = tmpSize - 1
For rmLoop = tmpCounter to tmpSize
tmpArray(0,rmLoop) = tmpArray(0,rmLoop+1)
tmpArray(1,rmLoop) = tmpArray(1,rmLoop+1)
tmpArray(2,rmLoop) = tmpArray(2,rmLoop+1)
Next
tmpArray(0,tmpSize+1) = ""
tmpArray(1,tmpSize+1) = ""
tmpArray(2,tmpSize+1) = 0
End If
End If
Next
End If
If (tmpSize = -1) Then
Redim tmpArray(2,0)
Session("cart") = null
Session.abandon
Else
Redim Preserve tmpArray(2,tmpSize)
Session("cart") = tmpArray
End If
If (cartitemshowall = "") Then
cartitemshow = cartitemremove
End If
End If
'------------clear all the cart-----------
If (cartitemreset <> "") Then
Response.Write "clearing cart
"
Session("cart") = null
Session.abandon
End If
'------------show-----------
If (cartitemshow <> "") Then
If IsArray(Session("cart")) Then
For i = 0 to UBound(Session("cart"),1)
For j = 0 to UBound(Session("cart"),2)
If ((Session("cart")(0,j) = cartname) and (Session("cart")(1,j) = cartitemshow)) Then
Order = true
End If
Next
Next
End If
Response.Write "