Forum Moderators: buckworks

Message Too Old, No Replies

estore product attribute

E-store

         

daone

4:39 pm on Apr 14, 2009 (gmt 0)

10+ Year Member



hey guys i am creating a shopping cart i would like to know how to add product attribute section to my cart. Any help would be appreciated.

rocknbil

7:29 pm on Apr 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard daone, I am presuming by attributes you mean options, such as size, color . . . . it could be anything.

And anything it should be, as well as as many as needed, and whether or not that attribute changes the price or adds to the price, or whether it's required or an add-on, which adds to the price. Don't "hard code" a product attribute in your cart, devise a method to allow you to add any option to any product as needed.

I have a couple posts here on this, the most recent one is described in detail in the database forum [webmasterworld.com].

But that's just "how I would do it." :-)

daone

4:35 am on Apr 15, 2009 (gmt 0)

10+ Year Member



Thanks rocknbil for your reply, yes i do mean color and size and yes i'm trying to create a form that will enable me to add the attribute to the products. But being a newbie to php and mysql i'm geting stuck on the php code to query the database and create the form as it seems very compex and cofusing.

At the moment i have the folowing tables products, category, product_attribute, product_option, product_option_valuesand product_option_value_to_prodcut_option. My issue is wher to start with the php code.. Any hel will appreciated.

rocknbil

5:30 pm on Apr 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you're going to have to experiment and learn, experiment and learn . . . there is no one-shot short answer.

select * from products;

This starts going through your product list in a while loop. One of those will be product id, which you use as a join on the options. While inside this while loop do a select to get the appropriate options for this product:

select * from option_types where product_id='$pid';

Let's say this returns two options color and size as "product option types" for this product. While still inside this while loop, do a third select and another while loop inside the first to get all the values for those associated with this product:

select * from options where option_id='$optionid' and product_id='$pid';

This lists all the options for color, then size; then you end the inner while loop and go on to the next product.

The multiple selects and nested while loops can be eliminated by a single complex select statement that joins all the tables, but start this way to get an understanding of how this would all work.