Suggestions on storing shopping cart info

Discussion in 'ASP .Net' started by Cirene, Aug 17, 2008.

  1. Cirene

    Cirene Guest

    I am writing a shopping cart app in asp.net.

    So far I created 2 classes, 1 for customer_info (name, address, email), 1
    for product_info (prodname, price, description).

    As the shopper adds things to the cart and navigates throught the site to
    shop more, should I store this info in a session var? What is the typical
    way? Should I create another class for cart and store an array of
    product_info to keep track of what's in the cart, etc...?

    What do you recommend?

    Thanks
     
    Cirene, Aug 17, 2008
    #1
    1. Advertising

  2. Cirene

    Cirene Guest

    Thanks Mark, as usual. I'll give it a try...

    "Mark Rae [MVP]" <> wrote in message
    news:%23AbW$...
    > "Cirene" <> wrote in message
    > news:%...
    >
    >> As the shopper adds things to the cart and navigates throught the site to
    >> shop more, should I store this info in a session var?

    >
    > That would work. Alternatively, if you want the customer to be able to
    > save the cart and come back to it later, you should save it to a
    > database...
    >
    >> Should I create another class for cart and store an array of product_info
    >> to keep track of what's in the cart, etc...?

    >
    > That's what I do, though I tend to use a generic e.g. Dictionary<int, int>
    > to store the ID of the purchased product along with the number of items
    > purchased...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Cirene, Aug 17, 2008
    #2
    1. Advertising

  3. Cirene

    Cirene Guest

    Would using a generic list (of these objects) be the best way to handle this
    in your opinion? Store that to a session var?

    "Mark Rae [MVP]" <> wrote in message
    news:%23AbW$...
    > "Cirene" <> wrote in message
    > news:%...
    >
    >> As the shopper adds things to the cart and navigates throught the site to
    >> shop more, should I store this info in a session var?

    >
    > That would work. Alternatively, if you want the customer to be able to
    > save the cart and come back to it later, you should save it to a
    > database...
    >
    >> Should I create another class for cart and store an array of product_info
    >> to keep track of what's in the cart, etc...?

    >
    > That's what I do, though I tend to use a generic e.g. Dictionary<int, int>
    > to store the ID of the purchased product along with the number of items
    > purchased...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Cirene, Aug 18, 2008
    #3
  4. Cirene

    Cirene Guest

    But to perisist it using a session var doesn't using a List allow you to
    easily access, add and remove items in the cart? Or should I just use an
    arraylist of the cart items?

    I was just looking at this and it seemed like a good idea...
    http://www.java2s.com/Code/VB/Generics/GenericListstoresGenericClass.htm

    By the way i'm not sure what "top-posting" is. I just hit "Reply to Group"
    in Outlook Express. :)

    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "Cirene" <> wrote in message
    > news:...
    >
    > [please don't top-post]
    >
    >>> That's what I do, though I tend to use a generic e.g. Dictionary<int,
    >>> int> to store the ID of the purchased product along with the number of
    >>> items purchased...

    >>
    >> Would using a generic list (of these objects) be the best way to handle
    >> this in your opinion? Store that to a session variable?

    >
    > No it wouldn't, otherwise that's what I'd be doing. I've never found any
    > need to persist anything other than the ID of the item bought together
    > with the number of items purchased.
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Cirene, Aug 18, 2008
    #4
  5. Cirene

    George Guest

    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "Cirene" <> wrote in message
    > news:...
    >
    > [please don't top-post]
    >
    >>> That's what I do, though I tend to use a generic e.g. Dictionary<int,
    >>> int> to store the ID of the purchased product along with the number of
    >>> items purchased...

    >>
    >> Would using a generic list (of these objects) be the best way to handle
    >> this in your opinion? Store that to a session variable?

    >
    > No it wouldn't, otherwise that's what I'd be doing. I've never found any
    > need to persist anything other than the ID of the item bought together
    > with the number of items purchased.
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net



    I would disagree... (as a guy who has some experience in a-commerce, my site
    www.mspiercing.com )
    Here are some thoughts (from 3 years experience of having web site).

    1. Items might have options ( and sometimes more than one option). Id of
    the item will be the same but color different.
    So if you want to keep them in memory then create clsItem object which goes
    into shopping cart (generic list is perfect). So it will have ItemId,
    Options selected, Quantity, Price and who knows what else...

    2. Why to have a price... In real word you will change a price... and you do
    not want to get a mad customer who added "green tv" to the shopping cart for
    5.95 and suddenly when he checked out that "green tv" became 10.45. Simply
    because you and people who work in the E-commerce store work during the day
    and changing prices right in a middle of the day when people are shopping..
    Keep that in mind.

    3. It's generally bad idea to keep shopping cart in memory. Simply because
    you want to see how many attempts were made to buy staff from you.. Believe
    it or not but 50% people do not complete purchase. They add staff to
    shopping cart but never proceed all the way to complete the order. And you
    want to see what people were looking at... So keep it in DB so you could
    look/analyze at it later... Or help out some customer who calls you and says
    that he wanted to buy "green tv" from you and added it to the shopping cart
    but his computer/internet died and he can not complete the order.

    4. Order table must have all information about items (price, name, ...)....
    So it becomes frozen in time. Person might want to look at his previous
    order (especially if its business customer and he needs to print out invoice
    for IRS) and he needs to se price he ordered this item for 6 month ago and
    not new price... Or if item was discontinued and removed from inventory...
    Still you need to show complete info... like name, picture....


    George.
     
    George, Aug 19, 2008
    #5
  6. Cirene

    Cirene Guest

    Many great suggestions and good points! Thanks! Let me mull it over and
    see if I have anything else to ask...

    "George" <> wrote in message
    news:%...
    > "Mark Rae [MVP]" <> wrote in message
    > news:%...
    >> "Cirene" <> wrote in message
    >> news:...
    >>
    >> [please don't top-post]
    >>
    >>>> That's what I do, though I tend to use a generic e.g. Dictionary<int,
    >>>> int> to store the ID of the purchased product along with the number of
    >>>> items purchased...
    >>>
    >>> Would using a generic list (of these objects) be the best way to handle
    >>> this in your opinion? Store that to a session variable?

    >>
    >> No it wouldn't, otherwise that's what I'd be doing. I've never found any
    >> need to persist anything other than the ID of the item bought together
    >> with the number of items purchased.
    >>
    >>
    >> --
    >> Mark Rae
    >> ASP.NET MVP
    >> http://www.markrae.net

    >
    >
    > I would disagree... (as a guy who has some experience in a-commerce, my
    > site www.mspiercing.com )
    > Here are some thoughts (from 3 years experience of having web site).
    >
    > 1. Items might have options ( and sometimes more than one option). Id of
    > the item will be the same but color different.
    > So if you want to keep them in memory then create clsItem object which
    > goes into shopping cart (generic list is perfect). So it will have
    > ItemId, Options selected, Quantity, Price and who knows what else...
    >
    > 2. Why to have a price... In real word you will change a price... and you
    > do not want to get a mad customer who added "green tv" to the shopping
    > cart for 5.95 and suddenly when he checked out that "green tv" became
    > 10.45. Simply because you and people who work in the E-commerce store work
    > during the day and changing prices right in a middle of the day when
    > people are shopping.. Keep that in mind.
    >
    > 3. It's generally bad idea to keep shopping cart in memory. Simply because
    > you want to see how many attempts were made to buy staff from you..
    > Believe it or not but 50% people do not complete purchase. They add staff
    > to shopping cart but never proceed all the way to complete the order. And
    > you want to see what people were looking at... So keep it in DB so you
    > could look/analyze at it later... Or help out some customer who calls you
    > and says that he wanted to buy "green tv" from you and added it to the
    > shopping cart but his computer/internet died and he can not complete the
    > order.
    >
    > 4. Order table must have all information about items (price, name,
    > ...).... So it becomes frozen in time. Person might want to look at his
    > previous order (especially if its business customer and he needs to print
    > out invoice for IRS) and he needs to se price he ordered this item for 6
    > month ago and not new price... Or if item was discontinued and removed
    > from inventory... Still you need to show complete info... like name,
    > picture....
    >
    >
    > George.
    >
     
    Cirene, Aug 19, 2008
    #6
  7. Cirene

    Cirene Guest

    Thanks as usual...

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Cirene" <> wrote in message
    > news:%...
    >
    > [top-posting corrected]
    >
    >>>>> That's what I do, though I tend to use a generic e.g. Dictionary<int,
    >>>>> int> to store the ID of the purchased product along with the number of
    >>>>> items purchased...
    >>>>
    >>>> Would using a generic list (of these objects) be the best way to handle
    >>>> this in your opinion? Store that to a session variable?
    >>>
    >>> No it wouldn't, otherwise that's what I'd be doing. I've never found any
    >>> need to persist anything other than the ID of the item bought together
    >>> with the number of items purchased.

    >>
    >> But to perisist it using a session variable doesn't using a List allow
    >> you to easily access, add and remove items in the cart?

    >
    > It may do, but it's completely unnecessary IMO and just takes up more
    > memory on your web server.
    >
    > Say you have a widget with a product ID of 24, and someone buys two of
    > them - what else do you need to persist other than {24, 2}...? Now, say
    > they return to the cart and buy an extra widget - all your code has to do
    > is to change {24, 2} to {24, 3} - could hardly be simpler...
    >
    >> Or should I just use an arraylist of the cart items?

    >
    > Use an arraylist if you absolutely have to - I prefer to use a
    > Dictionary<int, int>
    >
    >
    >> By the way i'm not sure what "top-posting" is.

    >
    > It's when people post their replies *above* the text that they're replying
    > to, which is completely opposite to the way that conversations work. When
    > you read an article in a newspaper, you don't read from the bottom-up...
    > Top-posting means that people are forced to read the conversation
    > backwards, e.g.
    >
    > A: Because it messes up the order in which people normally read text.
    > Q: Why is top-posting such a bad thing?
    > A: Top-posting.
    > Q: What is the most annoying thing in newsgroups?
    >
    >> I just hit "Reply to Group" in Outlook Express. :)

    >
    > Er, yes, so just move your cursor *below* the text that you're replying
    > to - it's really quite simple...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Cirene, Aug 19, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GeorgeF

    Perl Shopping Cart Scripts

    GeorgeF, May 21, 2005, in forum: Perl
    Replies:
    1
    Views:
    3,259
    James T
    May 22, 2005
  2. Bruce W...1

    Secure shopping cart example?

    Bruce W...1, Aug 26, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    600
    Bruce W...1
    Aug 27, 2003
  3. Mark Fox

    Shopping Cart Component Suggestions

    Mark Fox, Nov 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    382
    Jacob Yang [MSFT]
    Nov 4, 2003
  4. Milsnips

    storing a shopping cart in a cookie?

    Milsnips, Feb 24, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    660
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Feb 24, 2007
  5. Sean
    Replies:
    2
    Views:
    98
Loading...

Share This Page