Print Page | Close Window

ASP Shopping Cart - How to remember info?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10608
Printed Date: 31 March 2026 at 2:42pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP Shopping Cart - How to remember info?
Posted By: FLATLINE
Subject: ASP Shopping Cart - How to remember info?
Date Posted: 26 May 2004 at 1:32pm

Hello,

I need to build a shopping cart in ASP, but it's the first time I'm doing this. I'm quite experienced in ASP sites but there's only one thing that prevents me from doing this shopping cart easily:

I would like to ask how is it possible to save info such as the items that the customer adds to his cart, each item's quantity, price and productID, and other cart info such as payment method etc.

I was thinking that maybe this is possible to do with cookies in an array form, and then use FOR... EACH statements when displaying the info. For example:

The customer adds to his cart a product named "Vanilla", product ID 34, priced $13 and quantity of 2:

intProdID = Request("prod_id") // 34
Response.Cookie("items")( intProdID )("name") = Request("name") // Vanilla
Response.Cookie("items")( intProdID )("price") = Request("price") // 13
Response.Cookie("items")( intProdID )("qty") = Request("qty") // 2

And then when I want to display the info:

FOR EACH item IN Request.Cookie("items")

Response.Write(item " " & item("name") & " $" & item("price") & " x " &
item("qty") & "<br>"

NEXT

Will display:

34 Vanilla $13 x 2

Will something like this work? And how to write it correctly?

Thanks.



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Replies:
Posted By: Mart
Date Posted: 26 May 2004 at 1:35pm

It would work but it would be like this

item( intProdID )("name")

etc.

Or

For Each item in Request.Cookie("items")( intProdID ) etc.



Posted By: FLATLINE
Date Posted: 26 May 2004 at 1:40pm

No that's not right. What if I want to have several items? So, for example, the above code that I wrote would generate something like:

34 Vanilla $13 x 2
51 Popsky $15.7 x 1
22 Shroom $12.69 x 4

It needs to be able to handle several ProductID's.



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: FLATLINE
Date Posted: 26 May 2004 at 1:55pm

Here is an example of a code that works. It's part of an e-mail sending script:

For Each obj in request.form
body = body & obj & ": " & request.form(obj) & vbCrLf
Next

The result is this:

fieldname: fieldvalue
fieldname: fieldvalue
fieldname: fieldvalue

For example, if I have a form like this:

<input type="text" name="Name"><br>
<input type="text" name="Phone"><br>
<input type="text" name="Address><br>

The result would be:

Name: Joe Shmoe
Phone: 1-800-BLA
Address: Some st. 15

And that is something that I know it works for sure. If I try to use this method with the cookies, it should be:

<%
FOR EACH item IN Request.Cookie("items")
Response.Write("ProdID: " & item & "<br>")
Response.Write("Name: " & Request.Cookie("items")(item)("name") & "<br>")
Response.Write("Price: " & Request.Cookie("items")(item)("price") & "<br>")
%>

And so on... Or the first code that I wrote above... Any thoughts?



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: ljamal
Date Posted: 27 May 2004 at 3:30am
Just store the info a database and use the coookie to reference the primary key for the cart in the database.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: gavinc
Date Posted: 27 May 2004 at 4:39am

You might want to have a look at http://www.comersus.com - www.comersus.com  for a free asp shopping cart.

 

 



Posted By: FLATLINE
Date Posted: 27 May 2004 at 10:16am
That is a very good free shopping cart. But if I'm getting a free shopping cart, then I need one which has Hebrew language support.

-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net