r2-d2 Posted May 19, 2011 Share Posted May 19, 2011 Hi, I'm building a webshop and im stuck at the checkout. I'm using this Shopping Cart class http://www.webforcecart.com/manual.html The cart is stored as an object in $_SESSION[cart]. This method print_r($cart->get_contents()); would get this as output: Array ( [0] => Array ( [id] => 7 [qty] => 1 [price] => 11.00 [info] => Test [subtotal] => 11 ) [1] => Array ( [id] => 6 [qty] => 2 [price] => 19.00 [info] => White 0 [subtotal] => 38 ) ) In the table Order I would like to store order-id customer-id total products total quantity total price date In the table Orderrow I would like to store: order-id, product-id, product-name, quantity, price, subtotal I know i can get the order-id with the function mysql_insert_id() but how can i store each product in the array with their info in the table Orderrow? Or is there a better way to do this? please advice me, thank you. Link to comment https://forums.phpfreaks.com/topic/236904-shopping-cart-store-checkout-in-database/ Share on other sites More sharing options...
r2-d2 Posted May 19, 2011 Author Share Posted May 19, 2011 i think i dont have to do a POST? because the products are already in the session. I just have to take it from the session and do query. make a class and do something like $new_category->name = $_POST['cat_name']; $new_category->parent_id = $_POST['cat_parent_id']; $new_category->description = $_POST['cat_description']; $new_category->position = $_POST['cat_position']; $new_category->visible = $_POST['cat_visible']; // cat_name can not be empty if (!empty($new_category->name)) { if($new_category->save()) { ^^ thats just a code from a different script. But how i can i do this for each ordered product? Link to comment https://forums.phpfreaks.com/topic/236904-shopping-cart-store-checkout-in-database/#findComment-1217805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.