Jump to content
Larry Ullman's Book Forums

Create dropdown options for different products

Recommended Posts

Hi Larry,

Hope you are well.

Regarding the 1st edition of your ecommerce book:

I am using the non coffee products concept(on page 198) in my own application because I want the user to be able to see a list of different products like on page 198, figure 8.6, when they choose a particular category.

But what I want is for there to be a dropdown next to each individual product , like on page 219, (figure 8.15), that lists the different sizes available for each individual product, and everytime the user selects a different size, the price changes accordingly for that individual product.

So basically, if we look at your application for example, when the user selects the 'GOODIES' tab, then selects the Mugs option, they are presented with a list of diffent Mugs they can buy, ie, 'Red Dragon', and 'Pretty Flower Coffee Mug'.

Say now that each mug come in small, medium and Large sizes.

i) would like for there to be a select dropdown next to each Mug option, that displays the different sizes available, just like in the coffee section, but I would like, when the user selects an option, say the large option for a mug, the price for the large mug will change accordingly, and thus be displayed alongside it, similarly an automatic price change for the small and medium  mug options also.

ii)I would also like to create a product_details page, so when the user clicks on say the 'Red Dragon Mug', they will be taken to a dedicated page that displays more details about the particular mug, giving them the option to add the mug to the shopping cart.

iii) When the user goes to the shopping cart, I would like the size of the product to be displayed alongside each item, so the user can see exactly what size item they are purchasing.

Please could you help me in achieving the three tasks above, because I have really tried, but I keep getting my code wrong. I'm still in the learning process, so I don't have enough knowledge and experience to implement exactly what I want.

So I would really appreciate your help.


Thank you!



Link to comment
Share on other sites

Ah, okay. This is definitely do-able, but not simple. To start, you'll need a way of reflecting sizes for non-coffees. An option would be to replicate the coffee database structure. Note that if somethings might have multiple sizes and other things might not, you'll need to account for that. 

For the automatic price change, you'll need to use JavaScript. When the size selection changes, the JavaScript would fetch the information for that size from another PHP script (using an XHR request). Or you could do some sort of logic where the display PHP stores the new price as metadata on the menu and then the JavaScript parses that out. In either case, you'll need to use JavaScript. 

For the product details page, follow the specific coffees page as a model, passing along the specific product ID and then fetching it from the database. 

For the shopping cart with a sized product, just replicate what's being done with the coffees. 

Let me know if you have any more questions and good luck!

Link to comment
Share on other sites

Thanks Larry!


It sounds like a very tall order, especially for a newbie like myself, but I will definitely give it a go!!


No doubt, I will run into problems where I will need your help, but I will exhaust every option before requesting your help!


Thanks again!!

Link to comment
Share on other sites


  • Create New...