Adding multiple items into cart

Discussion in 'PHP' started by shooka, May 16, 2006.

  1. #1
    Hi, im currently finishing a e-commerce site and i have a problem with adding multiple items from different categories into cart in one button press.

    Its a kitesurfing site, and categories divided to: size / bar / colour / lines.

    i want the users to choose 1 or more options and all to be added to the cart.

    I attached the code for the relevant page beneath.

    Please contact me if you need anything else...

    Thank you in advance...

    Shooka

    <?php
    //WA eCart Include
    require_once("../WA_eCart/blade_cart_PHP.php");
    session_start();
    ?>
    <?php require_once('../Connections/blade.php'); ?>
    <?php
    $blade_cart->GetContent();
    ?>
    <?php
    $maxRows_Recordset1 = 5;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
    $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

    $colname_Recordset1 = "-1";
    if (isset($_POST['size'])) {
    $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_POST['size'] : addslashes($_POST['size']);
    }
    mysql_select_db($database_blade, $blade);
    $query_Recordset1 = sprintf("SELECT ProdID, ProdName, ProdPrice FROM products WHERE ProdID = %s", $colname_Recordset1);
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $blade) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);

    if (isset($_GET['totalRows_Recordset1'])) {
    $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
    $all_Recordset1 = mysql_query($query_Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    }
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    ?>
    <?php
    // WA eCart AddToCart
    if (isset($_POST["blade_cart_1_ATC"]) || isset($_POST["blade_cart_1_ATC_x"])) {
    $ATC_itemID = $_POST["blade_cart_1_ID_Add"];
    $ATC_AddIfIn = 2;
    $ATC_RedirectAfter = "../shopping_cart/cart.php";
    $ATC_RedirectIfIn = "";
    $ATC_itemName = "".$row_Recordset1['ProdName'] ."";// column binding
    $ATC_itemDescription = "testdesc";// column binding
    $ATC_itemWeight = floatval("0");// column binding
    $ATC_itemQuantity = "".$_POST["blade_cart_1_Quantity_Add"] ."";// column binding
    $ATC_itemPrice = floatval("".$row_Recordset1['ProdPrice'] ."");// column binding
    $ATC_itemQuantity = floatval($ATC_itemQuantity);
    if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
    $blade_cart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice);
    if ($ATC_RedirectAfter != "" && $blade_cart->redirStr == "") {
    $blade_cart->redirStr = $ATC_RedirectAfter;
    }
    if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
    $_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
    }
    else {
    $_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
    }
    }
    }
    ?><?php
    // WA eCart Redirect
    if ($blade_cart->redirStr != "") {
    header("Location: ".$blade_cart->redirStr);
    }
    ?>
    <html><!-- InstanceBegin template="/Templates/blade_template.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>

    <style type="text/css">
    <!--
    .style17 {
    color: #FFFFFF;
    font-weight: bold;
    }
    .style22 {font-family: Verdana, Arial, Helvetica, sans-serif}
    .style23 {
    color: #FFFFFF;
    font-weight: bold;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10px;
    }
    .style32 {color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
    body {
    margin-top: 0px;
    background-image: url(../images/home/bg.gif);
    }

    .style18 {font-size: 12px}

    a.links1:link {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #330099; text-decoration: none}
    a.links1:visited {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #330099; text-decoration: none}
    a.links1:hover {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; color: #330099}

    a.links2:link {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 10px; color: #FFFFFF; text-decoration: none}
    a.links2:visited {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 10px; color: #FFFFFF; text-decoration: none}
    a.links2:hover {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 10px; color: #CCFF99}
    .style19 {color: #FFFFFF}

    -->
    </style>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
    }

    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_findObj(n, d) { //v4.01
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    <link href="../WA_eCart/CSS/WAeCartStyles_S5a.css" rel="stylesheet" type="text/css">
    <link href="../WA_eCart/CSS/WAeCartStyles_S2a.css" rel="stylesheet" type="text/css">
    </head>
    <body onLoad="MM_preloadImages('../images/home/specialofferroll.gif','../images/home/galleryroll.gif','../images/shopping/customize/kite_black_red.jpg','../images/shopping/customize/kite_blue_gray.jpg','../images/shopping/customize/kite_blue_red.jpg','../images/shopping/customize/kite_red_gray.jpg')">
    <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="780" height="15" align="left" background="../images/home/upbar.gif" bgcolor="#FFFFFF"><table width="781" height="15" border="0" cellpadding="0" cellspacing="0">
    <tr class="style18">
    <td width="420" height="15"><span></span></td>
    <td width="65"><span><a href="../shopping_cart/cart.php" class="links2">view cart </a></span></td>
    <td width="11"><span class="style19">|</span></td>
    <td width="284"><span><strong><a href="../shopping_cart/login.php" class="links2">check out </a></strong></span></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td height="173" align="left"><!-- InstanceBeginEditable name="flash" -->
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="174">
    <param name="movie" value="../images/flash/home.swf">
    <param name=quality value=high>
    <param name="SCALE" value="exactfit">
    <embed src="../images/flash/home.swf" width="780" height="174" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>
    </object>
    <!-- InstanceEndEditable --></td>
    </tr>
    <tr>
    <td height="391" valign="top"><table width="780" height="300" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="59">&nbsp;</td>
    <td width="4" background="../images/home/sideline2.gif"></td>
    <td width="15" valign="top" bgcolor="#FFFFFF"></td>
    <td width="626" valign="middle" bgcolor="#FFFFFF"><!-- InstanceBeginEditable name="main" -->
    <table width="100%" height="341" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="28%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="55">&nbsp;</td>
    </tr>
    <tr>
    <td height="225"><div align="center"><img src="../images/shopping/customize/kite_black_red.jpg" name="kite" width="100" height="138" id="kite"></div></td>
    </tr>
    </table>
    </td>
    <td width="72%" height="341" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="31" valign="bottom"><img src="../images/shopping/customize/customize_headline.gif" width="452" height="19"></td>
    </tr>
    <tr>
    <td height="338"><form name="blade_cart_1_ATC_0" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="23%">&nbsp;</td>
    <td width="21%">&nbsp;</td>
    <td width="21%">&nbsp;</td>
    <td width="35%">&nbsp;</td>
    </tr>
    <tr>
    <td><span style="font-weight: bold">Size</span></td>
    <td>&nbsp;</td>
    <td><span style="font-weight: bold">Bar</span></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="120" valign="top"><p>
    <label>
    <input type="radio" name="size" value="2" checked>
    8 meter</label>
    <br>
    <label>
    <input type="radio" name="size" value="3">
    10 meter</label>
    <br>
    <label>
    <input type="radio" name="size" value="4">
    12 meter</label>
    <br>
    <label>
    <input type="radio" name="size" value="5">
    14 meter</label>
    <br>
    <label>
    <input type="radio" name="size" value="6">
    16 meter</label>
    <br>
    <label></label>
    </p>
    </td>
    <td valign="top"><?php do { ?>
    <table width="100%" height="20" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td>($<?php echo $row_Recordset1['ProdPrice']; ?>)</td>
    </tr>
    </table>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></td>
    <td valign="top"><p>
    <label>
    <input type="radio" name="bar" value="8" checked>
    45cm</label>
    <br>
    <label>
    <input type="radio" name="bar" value="9">
    50cm</label>
    <br>
    <label>
    <input type="radio" name="bar" value="10">
    55cm</label>
    </p></td>
    <td valign="bottom">&nbsp;</td>
    </tr>
    <tr>
    <td><span style="font-weight: bold">Color</span></td>
    <td>&nbsp;</td>
    <td><span style="font-weight: bold">Lines</span></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td valign="top">
    <p>
    <label>
    <input name="Color" type="radio" onClick="MM_swapImage('kite','','../images/shopping/customize/kite_black_red.jpg',1)" value="radio">
    </label>
    <img src="../images/shopping/customize/pallete_black_red.gif" width="50" height="13"><br>
    <label>
    <input name="Color" type="radio" onClick="MM_swapImage('kite','','../images/shopping/customize/kite_blue_gray.jpg',1)" value="radio">
    </label>
    <img src="../images/shopping/customize/pallete_blue_gray.gif" width="50" height="13"><br>
    <label>
    <input name="Color" type="radio" onClick="MM_swapImage('kite','','../images/shopping/customize/kite_blue_red.jpg',1)" value="radio">
    </label>
    <img src="../images/shopping/customize/pallete_blue_red.gif" width="50" height="13"><br>
    <label>
    <input name="Color" type="radio" onClick="MM_swapImage('kite','','../images/shopping/customize/kite_red_gray.jpg',1)" value="radio">
    </label>
    <img src="../images/shopping/customize/pallete_red_gray.gif" width="50" height="13"><br>
    </p></td>
    <td>&nbsp;</td>
    <td valign="top"><p>
    <label>
    <input type="radio" name="lines" value="11" checked>
    22m set</label>
    <br>
    <label>
    <input type="radio" name="lines" value="12">
    25m set</label>
    <br>
    <label>
    <input type="radio" name="lines" value="13">
    27m set</label>
    <br>
    </p>
    <br>
    </td>
    <td valign="top">&nbsp;</td>
    </tr>
    </table>








    <input type="hidden" name="blade_cart_1_ID_Add" value="<?php echo((isset($_POST["size"]))?$_POST["size"]:"") ?>" >
    <input type="text" name="blade_cart_1_Quantity_Add" value="1" size="4" >
    <input type="submit" value="Add To Cart" name="blade_cart_1_ATC">
    </form>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <!-- InstanceEndEditable --></td>
    <td width="15" valign="top" bgcolor="#FFFFFF"></td>
    <td width="4" background="../images/home/sideline.gif">&nbsp;</td>
    <td width="57">&nbsp;</td>
    </tr>
    </table>
    <table width="780" height="105" border="0" cellpadding="0" cellspacing="0" background="../images/home/bottombar.gif">
    <tr>
    <td height="31" colspan="11">&nbsp;</td>
    </tr>
    <tr>
    <td width="89" height="42">&nbsp;</td>
    <td width="222" valign="bottom"><div align="left"><a href="../special_offers.php" onMouseOver="MM_swapImage('Image1','','../images/home/specialofferroll.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="../images/home/specialoffer.gif" name="Image1" width="116" height="29" border="0" id="Image1"></a></div></td>
    <td width="42" valign="bottom"><a href="../index.php"><img src="../images/nav_links/home.gif" width="32" height="14" border="0"></a></td>
    <td width="15" valign="bottom"><span class="style17">|</span></td>
    <td width="60" valign="bottom"><span class="style17"><a href="../company.php"><img src="../images/nav_links/company.gif" width="48" height="14" border="0"></a></span></td>
    <td width="14" valign="bottom"><span class="style17">|</span></td>
    <td width="53" valign="bottom"><a href="../support.php"><img src="../images/nav_links/support.gif" width="45" height="14" border="0"></a></td>
    <td width="35" valign="bottom">&nbsp;</td>
    <td width="20" valign="bottom">&nbsp;</td>
    <td width="136" valign="bottom"><div align="right"><a href="../gallery.php" onMouseOver="MM_swapImage('Image2','','../images/home/galleryroll.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="../images/home/gallery.gif" name="Image2" width="117" height="29" border="0" id="Image2"></a></div></td>
    <td width="94" valign="bottom">&nbsp;</td>
    </tr>
    <tr>
    <td height="32" colspan="11">&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($Recordset1);
    ?>
     
    shooka, May 16, 2006 IP
  2. drionix

    drionix Peon

    Messages:
    189
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hmm.. you did not include the function for:
    $blade_cart->AddToCart()
     
    drionix, May 17, 2006 IP