Page 1 of 1

Custom form with addtocart function problem (no product id t

Posted: Tue Jul 01, 2014 11:47 pm
by haozzi
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:

http://www.mediafire.com/convkey/40aa/5 ... cct8fg.jpg

Code: Select all

<div class="custom_order">
<fieldset>
    <legend>Order Custom Mug here</legend>
        <br />
	<form id="custom_orderForm" name="custom_orderForm" method="post" action="custom_cart.php">
    <table width="100%" border="1" cellspacing="0" cellpadding="6">
      <tr>
        <td align="center" width="15%" bgcolor="#C5DFFA"><strong>Mug Moder</strong></td>
        <td align="center" width="15%" bgcolor="#C5DFFA"><strong>Size</strong></td>
        <td align="center" width="15%" bgcolor="#C5DFFA"><strong>Color</strong></td>
        <td align="center" width="25%" bgcolor="#C5DFFA"><strong>Message/Text will print at the mug</strong></td>
        <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Quantity</strong></td>
        <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Price</strong></td>
        <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Total</strong></td>
      </tr>
      <tr>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="15%"><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></td>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="25%"><label>
        	<input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label></td>
        <td align="center" width="10%"><label>
        	<input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label></td>
      </tr>
      <tr>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="15%"><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></td>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="25%"><label>
        	<input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label></td>
        <td align="center" width="10%"><label>
        	<input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label></td>
      </tr>
      <tr>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="15%"><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></td>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="25%"><label>
        	<input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label></td>
        <td align="center" width="10%"><label>
        	<input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label></td>
      </tr>
      <tr>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="15%"><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></td>
        <td align="center" width="15%">
        	<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></td>
        <td align="center" width="25%"><label>
        	<input id="custom_mugMessage" name="custom_mugMessage" type="text" size="40" /></label></td>
        <td align="center" width="10%"><label>
        	<input id="custom_mugQty" name="custom_mugQty" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugPrice" name="custom_mugPrice" type="text" size="6" /></label></td>
        <td  align="center" width="10%"><label>
        	$<input id="custom_mugTotal" name="custom_mugTotal" type="text" size="6" /></label></td>
      </tr>
      <tr>
      	<td>Cart Grand Total:</td>
      </tr>
    </table>
    	<div style="text-align:center; margin-top:0.3em;">
    		<input id="custom_mugButton" name="custom_mugButton" type="submit" value="Add to Shopping Cart" />
        </div>
    </form>
</fieldset>
</div>

Re: Custom form with addtocart function problem (no product

Posted: Wed Jul 02, 2014 6:08 am
by Celauran
All you'd really need to do is save the details of each mug as an array inside your session data. The problem I see here is that you have a form where each row has a field with the same name, and those aren't being saved as an array. If I order four mugs, you'll only get information about one.