Subject: add multiple items to cart
Posted By: saf Post Date: 1/6/2007 4:19:30 AM
Hoping someone can point me in the right direction...

I'm trying to modify the Webshop application.  I don't necessarity need to maintain an active shopping cart throughout the session.  I want to display a list of available products, each with an editable quantity field.  The user will enter the quantity of each item they want to order then add all the products to the database at one time (I could potentially have anywhere from 100-300 different items added at a time). I'm struggling with a few things:

1) I know this one should be easy but I've been struggling for days...  I can't figure out the code to add multiple items (orderedProducts) to the cart at one time.  

2)  Since I will have so many products being ordered at one time, will I take a performance hit by adding them to a 'cart' in memory before finalizing the order?  If so, instead of adding them to a 'cart' I can just add them to the database - I would still want to show the user their order and allow them to make changes during the current session, then just update the database again before final confirmation of order.

Thanks!

Reply By: Imar Reply Date: 1/6/2007 8:16:07 AM
Hi there:

1. You can call ShopManager.AddProductToCart multiple times, each time passing a single product to it.
Alternatively, you could write an overload for AddProductToCart that accepts a List (Of Product) or an Array of Products and adds them to the cart.

2. Products are very light weight objects; you need to store a whole lot of products in the cat before you'd notice memory issues.
However, if you're worried about that, you could store the cart in the Profile. You can define a property of type ShoppingCart in the web.config and the shopping cart can then be saved in the database through the Profile feature of ASP.NET.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply By: saf Reply Date: 1/8/2007 9:57:16 AM
Thanks for the quick response Imar
saf

Reply By: Imar Reply Date: 1/8/2007 1:50:33 PM
You're welcome. Did it help? What method did you choose?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Go to topic 54259

Return to index page 70
Return to index page 69
Return to index page 68
Return to index page 67
Return to index page 66
Return to index page 65
Return to index page 64
Return to index page 63
Return to index page 62
Return to index page 61