Wednesday, October 25, 2006

Profile and storing a shopping cart

So i want to build a shopping cart into my ecommerce site..

This is how i implemented it...


1) created a shopping cart and shopping cart item concept clases (see this blog entry "generics - shopping cart" for the design of the classes)

2) Because the shopping cart is at the level of the user im gonna use the Profile object to store it. A huge advantage of the Profile architecture is that it is generic enough to allow me to store arbitary types and supports a multitude of persistence methods. In my case im gonna store the persisted class into the profile object.. awesome!


<profile enabled="true">
---<properties>
------<add serializeas="Binary" allowanonymous="true" type="SampleCode.ShoppingCart" name="ShoppingCart">
---</properties>
</profile>


And to use the shopping cart from within code is this simple:

---Profile.ShoppingCart.Items.Add( new Item("Chocolate covered cherries", 3.95F));

No comments: