Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP Shopping Cart - How to remember info?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP Shopping Cart - How to remember info?

 Post Reply Post Reply
Author
FLATLINE View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2002
Location: Israel
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote FLATLINE Quote  Post ReplyReply Direct Link To This Post Topic: ASP Shopping Cart - How to remember info?
    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.



Edited by FLATLINE
Visit my site: DarkGreen HQ
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
FLATLINE View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2002
Location: Israel
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote FLATLINE Quote  Post ReplyReply Direct Link To This Post 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: DarkGreen HQ
Back to Top
FLATLINE View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2002
Location: Israel
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote FLATLINE Quote  Post ReplyReply Direct Link To This Post 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?



Edited by FLATLINE
Visit my site: DarkGreen HQ
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
gavinc View Drop Down
Newbie
Newbie


Joined: 20 November 2003
Location: Wales
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote gavinc Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2004 at 4:39am

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

 

 

Back to Top
FLATLINE View Drop Down
Groupie
Groupie
Avatar

Joined: 08 July 2002
Location: Israel
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote FLATLINE Quote  Post ReplyReply Direct Link To This Post 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: DarkGreen HQ
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.