annebuena Posted September 2, 2013 Share Posted September 2, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/ Share on other sites More sharing options...
fastsol Posted September 2, 2013 Share Posted September 2, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447855 Share on other sites More sharing options...
annebuena Posted September 2, 2013 Author Share Posted September 2, 2013 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! Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447862 Share on other sites More sharing options...
fastsol Posted September 2, 2013 Share Posted September 2, 2013 Well first, how are you wanting to distinguish one sale from another in the db? Usually you would have a transaction id that is unique to the sale, but you aren't actually making a sale? So how do you want to generate that id? Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447864 Share on other sites More sharing options...
jcbones Posted September 2, 2013 Share Posted September 2, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447868 Share on other sites More sharing options...
annebuena Posted September 3, 2013 Author Share Posted September 3, 2013 @fastsol: Yeah, I will use a transaction id in order to distinguish each. Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447950 Share on other sites More sharing options...
annebuena Posted September 3, 2013 Author Share Posted September 3, 2013 @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 . Quote Link to comment https://forums.phpfreaks.com/topic/281789-shopping-cart-problem/#findComment-1447951 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.