Shopping cart project - product options

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ade234uk
Forum Newbie
Posts: 2
Joined: Sat Mar 04, 2006 5:45 am

Shopping cart project - product options

Post by ade234uk »

I am creating my own shopping cart again, to see how much I know about PHP.
This is a project I come back to every 6 months or so, but when I start again I then realise what a task it is going to be.

One thing that is stopping me moving forward is the option to create options for the product and the best way of doing it. I think the way I am doing it is wrong.

I have shoes for sale
The user can select the size

I have T-Shirts for sale
The user can select the size
The user can also select the colour

Now I have sorted something out. I basically check to see if the product_options_group_id field in the products table has some id numbers.

In this example the T-Shirts product have the following numbers in the product_options_group_id field, The number 1,2, relate to the T-Shirt size and T-Shirt colour.

To display the drop down menus, if the numbers exist they are put into a foreach loop, and each number queries the product_options table and pulls out the information and creates an option value. The mysql query groups the product_options_group_id numbers together, which is how it creates the drop down menus underneath each product.

I hope the above makes some sort of sense. If you have created your own cart, what did you do for product options and what was the best way forward. I feel that I am going around this the wrong way, so your help would be appreciated.
Post Reply