Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

from cart table to order table, any suggestions?

Status
Not open for further replies.

slickwillyslim

Programmer
May 28, 2004
25
US
ok guys, this seems to be a tough scenario for me. i can update an order table all day long no problem, but if a customer doesn't complete an order (i.e. adds to the basket and closes the session before completing the order), then i need to clear out that order. what i decided to do was create a cart table seperate from the order table so that if a user ended their session before completing the order it would just clear the cart contents based solely on their sessionid. this should work fine and in the session on_end in the global i could clear the cart contents for each individual session. in theory the only orders written to the order table are orders that go through the order confirmation page. my problem is in writing everything i need from the cart table to the order table when the user completes the order. really all i need is to pull the product id, and the quantity from the cart table and write to the order table. the order number can be created at the confirmation page and the other fields will be repeated stuff like date, etc. i created a multiple product add page which pulled checkbox values(set as Prod id's) from a form on the product page. the user could check multiple products at once and add to cart. the checkbox values were put into an array and parsed and looped into the cart table along with the other repeated fields (date, sessionid, etc.). this works fine with only one field like "prod id". but i need to be able to write all the products from the cart to the order table simultaneously upon order confirmation, which requires both the "Prod id" and "Quantity". i don't know how to create a vbScript array that will parse two sets of values simultaneously and then loop into the Order table. guess i'm trying to create a two-dimensional array but i don't know how. does anybody know how to do this or have a suggestion for another method? i'm open to suggestions, i just want the system to work so that simultaneous users don't get jumbled in the order process. thanks bunches for any suggestions :)
 
I have a different road

Why use the database when they add things to the cart? It would be easier for you and your database IF you used a cookie, when they first hit the site make it or check for it. just update everthing there, so if they leave, no big deal, if they go to the checkout, then read the cookie and update your table. That will take care of your worring about session.end and left over info in the table.


Sounds like you have done a lot of work so far on it, but... after reading your problems. This would be a simplier way to go. If you worry about no cookies enabled, try making a cookie, then check for it, if it's not made, redirect them to a page on why they need to enable it.

Thats just my two cents.
 
Keep the values in session variables. Use the Scripting.Dictionary object instead of an array.
 
hey i appreciate the cookie suggestion, but thought of that in the beginning. i was trying to avoid the use of cookies for the sake of some customers who despise them. i will use them as a last resort but i'm not quite ready to give up on sessions just yet. thanks though.
 
merinero,

sounds like a good idea, do you have any examples of how this works, or do you know where i might find an example relevent to my situation?
 
well it's better to use cookies at least in a small scale, one of the issues i encountered before is say on checkout, they get all ready to checkout and boom , they forgot their wallet in the car, then hop outside, come back in and mind you a slow typist, and take longer than the session timeout to checkout, and voila empty shopping cart, if you're going anti cookies, and imediate cleanup routines on session, you're going to have to add alot of embedded stuff into the pages to avoid content losses.

as for cleaning out the shopping carts, one way i did it in the past was an application variable... LastCleaned , application_onstart has LastCleaned set to 01/01/1950 , you can use a conditional to setup your cleaning timeframe like every hour, every day , every week whatever, when you run a cleaning cycle update teh application last cleaned value
and fire the cleaning cycle on session_onstart that way the connecting clients clean your db for you on your schedule, if you dont have that much traffic, then you dont have much to clean, and in turn not much to worry about, if you have alot of traffic, the conditional only checks against the lastcleaned application variable, and either fires it off, or skips it.
 
forgot to mention, in the shopping cart table, have a timestamp on the item records, that way you can use that as your cleaning filter, let shopping carts float for say a day /week / whatever .. also another good reason for cookies, people still use modems, and people still get disco'd on the internet, it's a nice feature to have their shopping cart contents waiting for them when they get back to the website.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top