ok basic concept:
you want to remember what the user is asking for.
then when they actually finish the purchase it needs to plop into the sql table for good.
use $_SESSION['cart'] or whatever to keep track of what the user is doing,
then when they user is ready to commit and finalize the order,
then translate your $_SESSION into sql code to store the thought for good
so you need a few things.
one sql representation of an order
one session representation of an order
some code that will create a sql statement out of you session
some code that will manipulate the specifics of your order - add item, remove item, etc
i recommend doing all your manipulation in php to your session version. then, when you are done, write the info into the database.
this way you don't need to have a SQL version of addItemToCart()
to do these things in a session is easy, as a _SESSION acts just like any other array. its just easier to keep the complicated logic out of SQL
add:
$_SESSION['cart']['items'][] = 'my item';
remove:
unset($_SESSION['cart']['items'][3]);
update
$_SESSION['cart']['items'][$id] = 'my udpated item';