Implementation of a shopping cart in PHP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Implementation of a shopping cart in PHP

Post by dimitris »

Can anyone explain to me how an electronic shopping cart could be implementated in PHP?

My first thought was to use a mysql database to store the orders!But this could overrun the database and i should have a proper control mechanism!

My second thought is a session array which would store ids of things which someone selects in through some pages!

I am a newbie in PHP and e-commerce techniques so any help would be very helpful to me! :roll:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

There's no problem using a db to store orders. Just clear out the old orders once in a while - either delete them or save as historical data somewhere.

Have a hunt around for some shopping cart tutorials and then see what you can come up with. If you have a problem with a specific script or php function, post in the Code forum. If it's more of a theory/design quesion post here.
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

Ok!I look for some tutorials but i wanted to have a clear view how a market cart works!
I mean i store all orders in a db but I am not sure what to do with them while the user has not verify them!
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

The answer to "how do I design a shoppng cart?" is really "how do you want to design it?".

You can store data in databases or files (databases preferred) and (temporarily) in sessions.

My best advice is that I think you ought to read up a bit more but I'll be glad to help when you've done that and have some specific questions.

If it's for a live site, you must have a thorough understanding of security issues relating to php, sql, etc. Except as an exercise, ecommerce systems are not something a beginner should attempt.
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

McGruff wrote: If it's for a live site, you must have a thorough understanding of security issues relating to php, sql, etc. Except as an exercise, ecommerce systems are not something a beginner should attempt.
Yes, it is for a live site and i try to do my best in order to understand sessions and other issues!Security is a thing i consider most.

Actually,I have implemented a login script and many of the pages that someone can view and choose products but i must think more about the market process!

I'll come up soon!
Thanks :idea:
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

dimitris wrote: Yes, it is for a live site and i try to do my best in order to understand sessions and other issues!Security is a thing i consider most.
Don't do it.

You obviously don't have the required knowledge going by the comments you made about databases and the fact that you are asking questions on a php forum. Do you know anything at all about security?

If it's your own business think of the damage that could be done if the site gets hacked and some cc numbers are stolen. If you're doing it for a client, think of the damage it could do to your reputation as a programmer.

Script kiddies getting in over their head on an ecommerce project are bad for the reputation of the internet as a secure place to do business

I'm telling you this for your own good.
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

I agree with McGruff
sounds like you're getting in over your head really fast. Its great to learn, but when you're learning at the expense of real people's credit card numbers thats a bad thing.

Pass the project to someone else, take a cut of it and get yourself some knowledge on the subject.

There are so many aspects when creating an e-commerce store. I created one from scratch with PHP that has done over 4 million last year so I speak from experience.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I agree with McGruff and JPlush (hey, for once, J ;) ). If you are a newbie to web-technolgies and PHP, the issues are simply too complex.

For step-by-step tutorial to shopping carts I would recommend "MySQL/PHP Database Applications" by Jay Greenspan and Brad Bulger.

Write an online shop that handles orders via email, i.e. once an order is placed an email gets sent to the supplier/owner of the shop. Don't ask for credit card details. Let the supplier/owner handle that on receipt of that order-email.
All you'll be processing is product details - no payment methods or anything else.

So strictly speaking: start off with an online ordering application. That will give you enough to do for a bit and you'll learn much more about PHP and web technologies.

However, do not even dream about integrating credit cards into that ordering system. That would be like asking around for a third party to grab the card details.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I was trying to say one thing clearly back there but, of course, I don't want to discourage you learning php. I hope you do stick at it and one day learn enough to write the mother of all shopping carts.
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

I agree with you guys that it is too risky for a newbie in php to implement an e-shop with cc !
In this situation i just want to implement it as an online order system where orders will be validated with phone calls and the payment will be via post or check or when the customer receives his packet!

Thank you all for your advice! As i said i'm doing my best! :!:
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

dimitris, that sounds like a really good start to e-commerce. Credit cards are the trickiest part of any shopping system.

http://www.zend.com has a good tutorial on starting a shopping cart
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

JPlush76 wrote:dimitris, that sounds like a really good start to e-commerce. Credit cards are the trickiest part of any shopping system.

http://www.zend.com has a good tutorial on starting a shopping cart
Thaks a lot! I'll see it at once! :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Can anyone point me towards a good tutorial on PHP and databases? Currently I just make sure register_globals is off..
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

By the way, dimitris in Greek equals to jim in english!
I find some good tutorials which look quite helpful
User avatar
dimitris
Forum Contributor
Posts: 110
Joined: Wed Jan 14, 2004 3:47 am
Location: Athens, Greece

Post by dimitris »

LiLpunkSkateR wrote:Can anyone point me towards a good tutorial on PHP and databases? Currently I just make sure register_globals is off..
There are a lot of good tutorials at:

http://hotwired.lycos.com/webmonkey
http://www.phpfreaks.com
http://www.freewebmasterhelp.com
http://www.php.net/tut.php

try some of them for a start!

P.S. I think that this question applies better to Code section!
Post Reply