Custom form with addtocart function problem (no product id to send), please help

Custom form with addtocart function problem (no product id to send), please help, tq.

Hi everyone,

I am building a shopping cart for a school exam. It is a custom mug order website. Basically, they want to let people custom design of the mug. I have set the order form like below, I am having some difficulty with the shopping cart. I took the basics of the shopping cart tutorial I found online. The only problem is that most shopping carts send an action and a product id through the URL and into the session for the shopping cart. Well, this custom order form have no id variable to send to cart, only the information will send. How would I code the addtocart.php to remenber all info using session, after yhat display the order detail in cart.php. I have tried manyday, but cannot get the entire thing to work. All help is appreciated. Below is my order form code:

[code]

custom_orderForm_img

Order Custom Mug here
<form id="custom_orderForm" name="custom_orderForm" method="post" action="custom_cart.php">
Mug Moder Size Color Message/Text will print at the mug Quantity Price Total
<select id="custom_mugModer" name="custom_mugModer"> <option value="mug_moder_x">Mug Moder X</option> <option value="mug_moder_y">Mug Moder Y</option> <option value="mug_moder_z">Mug Moder Z</option> </select> <label> <select id="custom_mugSize" name="custom_mugSize"> <option value="0.3l">0.3L</option> <option value="0.5l">0.5L</option> <option value="0.7l">0.7L</option> </select> <select id="custom_mugColor" name="custom_mugColor"> <option value="red">Red</option> <option value="blue">Blue</option> <option value="while">While</option> <option value="black">Black</option> </select> <label> <input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label> <label> <input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label> <label> $<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label> <label> $<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label>
<select id="custom_mugModer" name="custom_mugModer"> <option value="mug_moder_x">Mug Moder X</option> <option value="mug_moder_y">Mug Moder Y</option> <option value="mug_moder_z">Mug Moder Z</option> </select> <label> <select id="custom_mugSize" name="custom_mugSize"> <option value="0.3l">0.3L</option> <option value="0.5l">0.5L</option> <option value="0.7l">0.7L</option> </select> <select id="custom_mugColor" name="custom_mugColor"> <option value="red">Red</option> <option value="blue">Blue</option> <option value="while">While</option> <option value="black">Black</option> </select> <label> <input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label> <label> <input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label> <label> $<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label> <label> $<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label>
<select id="custom_mugModer" name="custom_mugModer"> <option value="mug_moder_x">Mug Moder X</option> <option value="mug_moder_y">Mug Moder Y</option> <option value="mug_moder_z">Mug Moder Z</option> </select> <label> <select id="custom_mugSize" name="custom_mugSize"> <option value="0.3l">0.3L</option> <option value="0.5l">0.5L</option> <option value="0.7l">0.7L</option> </select> <select id="custom_mugColor" name="custom_mugColor"> <option value="red">Red</option> <option value="blue">Blue</option> <option value="while">While</option> <option value="black">Black</option> </select> <label> <input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label> <label> <input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label> <label> $<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label> <label> $<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label>
<select id="custom_mugModer" name="custom_mugModer"> <option value="mug_moder_x">Mug Moder X</option> <option value="mug_moder_y">Mug Moder Y</option> <option value="mug_moder_z">Mug Moder Z</option> </select> <label> <select id="custom_mugSize" name="custom_mugSize"> <option value="0.3l">0.3L</option> <option value="0.5l">0.5L</option> <option value="0.7l">0.7L</option> </select> <select id="custom_mugColor" name="custom_mugColor"> <option value="red">Red</option> <option value="blue">Blue</option> <option value="while">While</option> <option value="black">Black</option> </select> <label> <input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label> <label> <input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label> <label> $<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label> <label> $<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label>
Cart Grand Total:
<input id="custom_mugButton" name="custom_mugButton" type="submit" value="Add to Shopping Cart" />
</form>
[/code]

It sounds like the shopping cart example uses a set of products (e.g. ones stored in your database) that have unique IDs. For example:

1 - White socks
2 - Red t-shirt
3 - Blue t-shirt

Therefore, it makes sense to send the ID of the product to be stored into the shopping cart.

As you are customising the products, you need to store customisations in the session instead of the product ID. You could use serialize and unserialize to put an array of customisations for one product into a format that can be stored in a session and then read it back from the session when you display it on a shopping cart page or create the actual order.

Sponsor our Newsletter | Privacy Policy | Terms of Service