dmx1 Posted January 16, 2022 Share Posted January 16, 2022 Hi Larry, Hope you are well. Qu 1: wanted to know, how would I change the price of a product based on the different sizes? So if a customer goes to the product details page for a product, it would have all the different size options. The product would have a default option with a default size. If the customer clicked on the small size the price would change according to that size. Similarly a price change for sizes medium and large. I could then add that size and price to the shopping cart. Qu 2: And lastly how would I allow the user to select different colors for the product, and be able to add that color product to the database? I could then add that color for that product to the shopping cart Thanks in advance Link to comment Share on other sites More sharing options...
Larry Posted January 21, 2022 Share Posted January 21, 2022 Hey! Good questions here! For question 1, there are two facets. First, the database needs to store the product+size+price combination, which is already supported. (I forget if the admin interface allows you to set different prices for different sizes or not.) Second, on the client-side (in the browser), you'll need to use JavaScript to make the magic happen. You'd use an event handler to watch for size changes and then update the price HTML accordingly. I think I'd be inclined to have the PHP script pull all the sizes and prices first, and store these in a JavaScript object. Then, when the size changes, the JavaScript uses that object to update the HTML. For question 2, with the current database structure you'd add a colors table and then a color column to the database, so you create a new SKU for each color. Hope that helps but let me know if you have additional questions. Link to comment Share on other sites More sharing options...
dmx1 Posted February 5, 2022 Author Share Posted February 5, 2022 I will try out your suggestions and let you know how far I have got to. Appreciate that Larry! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts