Jump to content


PHP Shopping Cart Help


  • You cannot reply to this topic
No replies to this topic

#1 Fourjays

    Young Padawan

  • Members
  • Pip
  • 30 posts
  • Location:Shropshire United Kingdom

Posted 10 November 2005 - 06:18 AM

Hi,
I am trying to make my own shopping cart system (for use on my own website, not for public distribution), and I am now at the point of doing the checkout process. Now I have everything figured out for it, except one thing...

How do I take the cart contents stored in the database, and insert it into the relevant orders order items table?

A simple rendition of my tables:

cart_cartcontents
- iid - pid - uid - productname - productprice - version -

cart_orders
- oid - uid - total - status -

cart_orderitems
- iid - oid - uid - name - price - dlid - version -


I guess the simple way to put what I want is like so;

User hits "checkout, placeorder, whatever". The script then inserts a new order into cart_orders. (simple enough I can do it this far) It then needs to read the cart_contents for this user, and insert whatever is in their cart into cart_orderitems with the corresponding oid to that of the one just entered into cart_orders. It then needs to delete their cart contents.

The only way I can think of doing this is to select the cart contents, and then put a query into a loop, for inserting it into cart_orderitems. I am sure there must be a better way of doing this. If I put a query into a loop, and the user has a large cart, we could be talking loads of queries...

Anybody got any ideas on how to do what I want, in a much better way?
Thanks

Edited by Fourjays, 10 November 2005 - 06:20 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users