Jump to content

id


raptor30506090

Recommended Posts

If English is not your first language, just try to say MORE on the subject so we can get an idea of what you mean.

 

What you need to be doing is storing the cart in the session using the product ID as the key:

 

$_SESSION['cart'][$productId] = array('quantity' => 5, 'price' => 9.99, 'options' => array( 'color' => 'green', 'size' => 'medium' ) );

Link to comment
Share on other sites

this is were im a bit stuck if they orderd

 

$_SESSION['cart'][$productId] = array('quantity' => 5, 'price' => 9.99, 'options' => array( 'color' => 'green', 'size' => 'medium' ) );

 

and then same person orderd

 

$_SESSION['cart'][$productId] = array('quantity' => 5, 'price' => 19.99, 'options' => array( 'color' => 'blue', 'size' => 'large' ) );

 

would that over right the first order?

 

thanks

Link to comment
Share on other sites

I don't know, that's a business rule.  What do you want to happen when they do that? 

 

If I bought 3 green shirts at $9.99, then 15 red shirts at $8.00, would you really make an entry for 18 shirts?  How would you ever figure out the original order?

 

If it were me, I'd probably use the same idea I gave you earlier, except $_SESSION['cart'][$productId] would be an array of products, each with their own quantities and specifications.  if all specifications matched, I'd update the quantity.  If any one of them did not match, I'd add a new row. 

 

Obviously, if $_SESSION['cart'][$productId] didn't already exist I'd add a new array of products, like this:

 

 

$_SESSION['cart'][$productId] = array( array( 'quantity' => 5, 'price' => 9.99, 'options' => array( 'color' => 'green', 'size' => 'medium' ) ) );

 

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.