PDA

View Full Version : best way to make a basket.. oh coding warriors


chris_angell
04-25-2005, 03:50 PM
Hello..

I am making a shopping cart.. I have no problem displaying products in a basket, passing over details is no problem from a products page. but I am stuck what to do after this.. ?? what is the best way to store this info. I have given sessions ago but i am just after a bit of advice before going ahead with this option.

this is what I have tried when storing to a session ?? i think I am doing it wrong.

link to basket from products,,, for example
addbasket.asp?id=12&name=name&price=price

now on the basket page

productNewSession = request.querystring("Id")
productName = request.querystring("name")
productPrice = request.querystring("price")
Session(productNewSession) = productNew + productName + productPrice


then display the the session ie...

Session("productNewSession")

is there a way to group a bunch of session vars under one name and call the values ie
Session("productNewSession").price the do something like

Session("productNewSession").price + 1

:confused:

i was going to use a new session for each product, i know this is wrong but I can't think how I can store the basket info ??

can I make a basket using a database ?? because I know how to add remove update record quite easily.. sessions are confusing me... all i need to do is add records to a session.. call the records, change the quantity and then pass this info on ???

any help ......... or any advice... I am pretty competent at asp but I have never really used sessions or applications.. ??

many thanks... hope this all makes scense........

miranda
04-25-2005, 10:29 PM
I wouldn't use sessions to hold the info. 1) they rely on cookies and some people shut them off. 2) they use server resources, which can be a detriment if it is a busy site.

You have a better idea when you said using a database to hold the information. You could then either store the information so the user can comeback and still have items in the basket, or delete old information by using a timestamp and then deleting records that are older than any given amount of time. or use a combination of both and instead of looking at minuts/hours on the timestamp look at days/weeks/months before deletion.

Bullschmidt
04-26-2005, 12:15 AM
And perhaps this may hopefully give you some ideas:

Classic ASP Design Tips - Shopping Cart
http://www.bullschmidt.com/devtip-shoppingcart.asp

I generally think of a shopping cart as a fancy name for a session array. And here is a good resource that includes how to use session arrays:

Session Object
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/iis/ref_vbom_seso.asp

And here are some more shopping cart resources:

Shopping Cart Sample
http://www.asp101.com/samples/viewasp.asp?file=shopping%2Easp

Welcome to the fake volleyball store
http://www.aspfaq.com/cart

And if you don't want to "roll your own," this resource has a list of free and commercial shopping cart components, as well as some pure ASP shopping carts:

Where can I get a shopping cart for my web site? - 4/11/2002
http://www.aspfaq.com/show.asp?id=2225

chris_angell
04-26-2005, 10:13 AM
Hi much thanks for replying. I was very interested in the using the database to store the values for my basket. If I was to do it this way.. things would be much easier..

BUT I still have a couple of problems.. I thought that you can't asign a database to a client ??? or do you make a new record for each user IE NEW ROW ?? if so what would be the best way to store the product information so it would be easy to add and remove records ??(would it be in one big string??) If it was one overall basket datadata, wounld't client A effect client B when updating products to the basket ??

also what you said about sessions.. were interesting.. because cookies are easy to understand. but I did't realise they function in a simular way :)

:o