Jump to content

Recommended Posts

Hi. I'm a php newbie and I just want to ask something. I have this simple Shopping Website, and I'm already done with the shopping cart which I learned from the phpacademy.org. Whenever the customer entered the final phase in ordering, I want all her orders to go to a table in my phpmyadmin database called 'transactions' so I can put up all the transactions made in one table. The problem is I cannot think of a way on how can I enter each item she ordered in the table. For example, she ordered 1 dress and 1 pants. Then these will be treated as 1 transaction right? But I want to save these to the table as 2. One row for pants and another for the dress. Can somebody help me? I'm really having a hard time. Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/
Share on other sites

I am familiar with that shopping cart.  What are you using to actually process the payment? PayPal?  You wouldn't want to perform the actions you are asking about until the payment has been taken.  If you are using the paypal IPN service then you would use a foreach loop to go through the posted vars and insert them into the db then.  If you are using a different service then can you post the code that is returned from the service to determine the payment has been processed and any additional info the service provides like an array of the items bought.  If you simply want to insert them into the db without taking into account these things then that is easy but not advised.

Hi thank you for that quick reply. I am thinking of using PayPal but it is not set yet. I am having trouble understanding that PayPal and Credit Card thing and I think I will do that later on. But hey, can you share me how to insert that without taking to any accounts? Or maybe the algorithm of it? I am in need sorry. Thank you!

The way I would do it is have a couple of different tables.

 

An item table

An order table

A item_order table

 

 

Items hold all of your items available (quantity, description, sku, price, etc).  The order table holds all the order details (transaction id, processed, total, etc). The item_order ties the orders to the items (via foreign keys).

 

This would require you to learn about data normalization, and relational database design.  This will save you headaches in the future with data collision.

Note** This is as simple of a design as it gets, you can go much more complex.  I would sit down and determine the features that I wanted, the data I expected to collect, then design the application from there.  Hacking it in later, is always a headache, and never turns out clean and bug free.

 

My 2 cents.

@jcbones: Thankyou. I made a point of sale with inventory system last semester and I am kinda familiar with what you said. I've done exactly what you just explained. But I did it using Visual Studio and now I need it in php. I'm still trying to fit in web development .

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.