Jump to content

Shopping Cart, Store checkout in database


r2-d2

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.