Zen Cart Logo
Forums / General Questions / Adding item with attributes from link

Adding item with attributes from link

Locked

Views: 984

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
11 Jun 2010, 3:47 PM
#1
marharri avatar

marharri

New Zenner

Join Date:
Jun 2010
Location:
oxford, ms
Posts:
3
Plugin Contributions:
0

Adding item with attributes from link

Ok, so I read the forums and came up with this php page to take the info from previous pages and submit it to the cart. The php page before it asks the last questions and sends all the data to this page which is not seen by the user. It seemed to work perfectly the first time; there was a slight delay as it ran the scripts, then it come to the correct product page saying "successfully added to cart!" I think I'm awesome. Then I click view cart. It's empty. I would appreciate any help other than, "send user to product page and have them choose attributes and add to cart from there." They need to be able to use the graphical site with full instructions on customization before it's added to the cart. Also, I realize some users don't have javascript to begin with. Here's my code.

<?php $font=$_GET['font']; $thread=$_GET['thread']; $text=$_GET['text']; $instructions=$_GET['instructions']; switch ($font) { case AKAFrivolity: $f="16"; break; case BoyzRGross: $f="10"; break; case CurlzMT: $f="11"; break; case GirlsAreWeird: $f="12"; break; case KristenITC: $f="13"; break; case PoorRichard: $f="14"; break; case TinkerToy: $f="15"; break; case Zachary: $f="17"; break; default: header( 'Location: cart/' ); } switch ($thread) { case red: $t="2"; break; case black: $t="3"; break; case babyblue: $t="4"; break; case babypink: $t="5"; break; case brown: $t="6"; break; case bubblegumpink: $t="7"; break; case white: $t="8"; break; case blue: $t="1"; break; case limegreen: $t="9"; break; default: header( 'Location: cart/' ); } ?> <form id="form_1" action="cart/index.php?main_page=product_info&cPath=7&products_id=1&number_of_uploads=0&action=add_product" method="POST"> <input type="hidden" name="id[1]" value="<? echo $f; ?>" id="attrib-1" /> <input type="hidden" name="id[2]" value="<? echo $t; ?>" id="attrib-2" /> <input type="hidden" name="id[txt_3]" value="<? echo $text; ?>" id="attrib-3-0" /> <input type="hidden" name="id[txt_4]" value="<? echo $instructions; ?>" id="attrib-4-0" /> </form> <script type="text/JavaScript"> function Submit(form){ document.getElementById(form).submit(); } Submit('form_1'); </script>
14 Jun 2010, 2:54 PM
#2
marharri avatar

marharri

New Zenner

Join Date:
Jun 2010
Location:
oxford, ms
Posts:
3
Plugin Contributions:
0

Re: Adding item with attributes from link

Bump. Anyone?

14 Jun 2010, 8:06 PM
#3
marharri avatar

marharri

New Zenner

Join Date:
Jun 2010
Location:
oxford, ms
Posts:
3
Plugin Contributions:
0

Re: Adding item with attributes from link

I figured it out myself. The quantity was not being set, so it was zero. This works:

<?php $font=$_GET['font']; $thread=$_GET['thread']; $text=$_GET['text']; $instructions=$_GET['instructions']; switch ($font) { case AKAFrivolity: $f="16"; break; case BoyzRGross: $f="10"; break; case CurlzMT: $f="11"; break; case GirlsAreWeird: $f="12"; break; case KristenITC: $f="13"; break; case PoorRichard: $f="14"; break; case TinkerToy: $f="15"; break; case Zachary: $f="17"; break; default: header( 'Location: cart/' ); } switch ($thread) { case red: $t="2"; break; case black: $t="3"; break; case babyblue: $t="4"; break; case babypink: $t="5"; break; case brown: $t="6"; break; case bubblegumpink: $t="7"; break; case white: $t="8"; break; case blue: $t="1"; break; case limegreen: $t="9"; break; default: header( 'Location: cart/' ); } ?> <form id="cart_quantity" action="cart/index.php?main_page=product_info&cPath=7&products_id=1&number_of_uploads=0&action=add_product" method="POST" enctype="multipart/form-data"> <input type="hidden" name="id[1]" value="<? echo $f; ?>" id="attrib-1" /> <input type="hidden" name="id[2]" value="<? echo $t; ?>" id="attrib-2" /> <input type="hidden" name="id[txt_3]" value="<? echo $text; ?>" id="attrib-3-0" /> <input type="hidden" name="id[txt_4]" value="<? echo $instructions; ?>" id="attrib-4-0" /> **<input type="hidden" name="cart_quantity" value="1" /> <input type="hidden" name="products_id" value="1" />** </form> <script type="text/JavaScript"> function Submit(form){ document.getElementById(form).submit(); } Submit('cart_quantity'); </script>