M
monki
I am trying to build a simple shopping cart
I am trying to store the contents of the cart in the session.
I have 2 questions
1) I am trying to see if the product is exists in the session, if it is
then rather than add the product again I want to add to the quantity of the
existing product
The code I am using is
_________________________________
strProd=request.form("ProdId")
strQty=request.form("Qty")
If Session(strProd)="" Then
Session(strProd) = strQty
Else
strOldQty=Session(strProd)
strNewQty=(strQty+strOldQty)
Session(strProd) = strNewQty
End if
_________________________________
Rather than adding the quantities the code puts the second qty after the
first I.e. 11 rather than 2
How do I get the addition to work. I have tried several different methods
but always get the same results?
2) Is this the best way of building a simple cart. I have thought about
just adding the cart into a database however I cant work out how to delete
the records if the session times out or is abandoned. I have looked at
Session_OnEnd but can not find any code examples of how this is used
Thanks in advance
J
I am trying to store the contents of the cart in the session.
I have 2 questions
1) I am trying to see if the product is exists in the session, if it is
then rather than add the product again I want to add to the quantity of the
existing product
The code I am using is
_________________________________
strProd=request.form("ProdId")
strQty=request.form("Qty")
If Session(strProd)="" Then
Session(strProd) = strQty
Else
strOldQty=Session(strProd)
strNewQty=(strQty+strOldQty)
Session(strProd) = strNewQty
End if
_________________________________
Rather than adding the quantities the code puts the second qty after the
first I.e. 11 rather than 2
How do I get the addition to work. I have tried several different methods
but always get the same results?
2) Is this the best way of building a simple cart. I have thought about
just adding the cart into a database however I cant work out how to delete
the records if the session times out or is abandoned. I have looked at
Session_OnEnd but can not find any code examples of how this is used
Thanks in advance
J