|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Shopping Cart Checkout Tutorial
Hi folks, I really got a lot out of the Cart tutorial.
There also seems to be quite a few people who need help with a check out section and im one of them. Is there anyone who could make us a demo script that would spit all the contents of the cart form the example at URL into a new table called "orders" that holds all the cart info (itemID and qty) and some user details like name, address, email from a form. Then we'd have all the pieces of the jigsaw together to go our own ways with it. Thanks David |
|
#2
|
|||
|
|||
|
I would definately appreciate some help with this as well. The shopping cart script works great, but I'm not familiar enough with PHP to figure out how to have it e-mail the contents of the cart and the results of a simple form (purchase info).
|
|
#3
|
|||
|
|||
|
i have done this.
first i created two tables called order and order_details. i also have a table for users first, when the user "checks out" i create an order which contains the ordernumber (primary key) and the users id (primary key on the users table). then i read from the cart table and put each itemID, qty into the table, but before i do this i run the mysql command mysql_insert_id(), this gets the ordernumber from the order table and i can then write this as the ordernum into the order_details table. so what you end up with (which does look messy, but works) is function SubmitOrder($billinguser, $deliveryuser, $amount, $gift) { //submit order into order_detail, retrieve its id and then submit order_contents with a parentid that equals the id of the matching data in order_detail $query_order="Insert into order (billuser, deluser, ordertime, gift) values ($billinguser, $deliveryuser, now(), $gift)"; mysql_query($query_order); $lastid=mysql_insert_id(); $select_cart="Select * from cart where cart.cookieId='" . GetCartId(). "'"; $result_select_cart=mysql_query($select_cart); while($row = mysql_fetch_array($result_select_cart)) { $book=$row["book"]; $cover=$row["cover"]; $qty=$row["qty"]; $insert_order="Insert into order_details(book, cover, qty, order_details_id) values ($book, $cover, $qty, $lastid)"; mysql_query($insert_order); } $query = "Delete from cart where cart.cookieId = '" . GetCartId() . "'"; mysql_query($query); setcookie ("cartId", "", time() - 3600); if anybody can improve this code to be better then please help |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Shopping Cart Checkout Tutorial |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|