Page 1 of 3
Can't adjust qty or remove first item in the cart
Posted: Sun Mar 20, 2011 8:26 pm
by mrzebra
I don`t know what I`m doing wrong but I can`t adjust the qty or remove the very first item in the cart. It is at array position 0. I can adjust other items in the cart but for some reason nothing happens to the very first item.
Here is my code for adding the item to the cart:
Code: Select all
<?php
// code to add item to the cart
if(isset($_POST['id'])) {
$found=false;
$i=0;
$id=$_POST['id'];
$product_id=$_POST['pid'];
$product_scent=$_POST['scent'];
$cartOutput="";
// if the cart session is empty
if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])<1) {
$_SESSION["cart_array"] = array();
array_push($_SESSION["cart_array"], array("id" =>$id, "product_id" => $product_id, "scent"=>$product_scent, "quantity" => 1 ));
sort($_SESSION["cart_array"],$product_id);
}else {
foreach($_SESSION["cart_array"] as $each_item) {
$i++;
// if the item is already in the cart, up the quantity by 1
if ($_SESSION['cart_array'][$i-1]['id']==$id) {
$_SESSION["cart_array"][$i-1]['quantity']++;
// sort the array by item ID
sort($_SESSION["cart_array"],$product_id);
$found=true;
} // close if
} // close foreach
if($found == false) {
array_push($_SESSION["cart_array"], array("id" =>$id, "product_id" => $product_id, "scent"=>$product_scent, "quantity" => 1 ));
sort($_SESSION["cart_array"],$product_id);
}
}
header("location: cart.php");
}
?>
Here is my code for adjusting or removing the item:
Code: Select all
<?php
/* code to adjust the item quantity in the cart. If the quantity is set to 0, the item will be removed from the cart */
if(isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") {
$adjust['id']= $_POST['item_to_adjust'];
$adjust['quantity']= $_POST['quantity'];
$i=0;
// find the item's array index
while($_SESSION['cart_array'][$i]['id']!=$adjust['id']) {
$i++;
}
foreach($_SESSION["cart_array"] as $each_item) {
if ($_SESSION['cart_array'][$i]['id']==$adjust['id'] ) {
// if the quantity is set to 0, remove the item from the cart
if ($adjust['quantity'] == 0) {
// remove the item from the cart
unset($_SESSION["cart_array"][$i]);
sort($_SESSION["cart_array"],$adjust['id']);
break;
}
else {
$_SESSION["cart_array"][$i]['quantity'] = $adjust['quantity'];
sort($_SESSION["cart_array"],$adjust['id']);
} // close else
} // close if
} // close foreach
sort($_SESSION["cart_array"],$adjust['id']);
//header("location: cart.php");
//exit();
}
?>
Does anyone have any ideas??
Re: Can't adjust qty or remove first item in the cart
Posted: Sun Mar 20, 2011 10:13 pm
by Jonah Bron
Lets just simplify that a bit and see if it's fixed.
Code: Select all
<?php
/* code to adjust the item quantity in the cart. If the quantity is set to 0, the item will be removed from the cart */
if(isset($_POST['item_to_adjust'], $_POST['quantity']) && ctype_digit($_POST['quantity'])) {
$id = $_POST['item_to_adjust'];
$quantity = intval($_POST['quantity']);
for ($i = 0; $i < count($_SESSION['cart_array']); $i++) {
if ($_SESSION['cart_array'][$i]['id'] == $id) {
if ($quantity == 0) {
unset($_SESSION['cart_array'][$i]);
} else {
$_SESSION['cart_array'][$i]['quantity'] = $quantity;
}
break;
}
}
//header("location: cart.php");
//exit();
}
?>
It would be easier if you used the product ID is the array index. Then no loop would be necessary.
Re: Can't adjust qty or remove first item in the cart
Posted: Tue Mar 22, 2011 12:29 am
by mrzebra
Nope that didn't work. How would I go about using the product Id as the index in an array of arrays? Would it be something like this:
Code: Select all
array_push($_SESSION["cart_array"], array($productId =>array("id" =>$id, "product_id" => $product_id, "scent"=>$product_scent, "quantity" => 1 )));
Re: Can't adjust qty or remove first item in the cart
Posted: Tue Mar 22, 2011 1:24 pm
by Jonah Bron
What do you mean "didn't work"? What happened? "didn't work" isn't how development works. There's a problem, it's cause, and a solution. Describe the symptoms.
Re: Can't adjust qty or remove first item in the cart
Posted: Tue Mar 22, 2011 7:16 pm
by mrzebra
Sorry...it will adjust all the other items in the cart except the first one. When I go to adjust or remove the first item in the cart the url displays this (if I want to change the first item's quantity to 2):
cart.php?quantity=2&item_to_adjust=40025&name=Body+Mist+150mL&scent=Bamboo+%26+Teak
All the information is right but it won't change it.
When i change the other items the url displays:
cart.php
And the item is adjusted properly.
There are no error messages being displayed.
Re: Can't adjust qty or remove first item in the cart
Posted: Tue Mar 22, 2011 9:12 pm
by Jonah Bron
Those two URLs, are you sure you don't mean the other way around?
Re: Can't adjust qty or remove first item in the cart
Posted: Tue Mar 22, 2011 10:08 pm
by mrzebra
Nope...that is the way the url displays when I click "update" to update the quantity of the item in the cart.
Re: Can't adjust qty or remove first item in the cart
Posted: Wed Mar 23, 2011 10:05 am
by Jonah Bron
If they're different, we need to see the code that generates the cart list with the quantity update form.
Re: Can't adjust qty or remove first item in the cart
Posted: Thu Mar 24, 2011 9:09 am
by mrzebra
Here is the code. Hopefully it isn't too confusing.
Code: Select all
<?php
/* code that outputs the cart contents and totals up the cart */
$cartOutput="";
$total="0";
$pp_checkout_btn="";
if(!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"])<1) {
$cartOutput= "<tr><td colspan=3 align=center><i><font face=arial color=#999999>Your shopping cart is empty</font></i></td><td></td><td></td></tr>";
} else {
// start Paypal Checkout Button
$pp_checkout_btn .='<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="shopping_url" value="http://www.coppercreekbathandbody.ca/mainProducts.php">
<input type="hidden" name="page_style" value="copperCreek">
<input type="hidden" name="cs" value="0">
<input type=hidden name="cmd" value="_cart">
<input type=hidden name="upload" value="1">
<input type=hidden name="business" value="my email goes here">';
// start the foreach loop to go through each item in the cart array
$i=0;
foreach($_SESSION["cart_array"] as $each_item) {
$item_id=$each_item['id'];
$prod_id=$each_item['product_id'];
// distiguish between a regular item and a gift box
switch ($prod_id) {
// if it is a $50 gift box
case "11":
$scent_id=substr($each_item['scent'],0,4);
$scent2_id=substr($each_item['scent'],4,4);
$scent3_id=substr($each_item['scent'],8,4);
$scent4_id=substr($each_item['scent'],12,4);
// Get product name and price
$sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1");
while ($row=mysql_fetch_array($sql)) {
$product_name=$row["productName"];
$price=$row["productPrice"];
}
// get Bath Butter Scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent=$row2['scentName'];
}
// get Body Scrub scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent2_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent2=$row2['scentName'];
}
// get Body Mist scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent3_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent3=$row2['scentName'];
}
// get Elite Hand Cream 120mL scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent4_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent4=$row2['scentName'];
}
$subtotal=$price*$each_item['quantity'];
$total=$subtotal + $total;
if(isset ($_SESSION["cart_array"] )) {
// dynamic checkout button assembly
$x=$i+1;
$pp_checkout_btn.='<input type=hidden name="item_name_'.$x.'" value="'.$product_name.'<br>FBB 8oz: '.$scent_id.', Scrub 8oz: '.$scent2_id.', Mist 150mL: '.$scent3_id.', Cream 60mL: '.$scent4_id.'<br> ">
<input type=hidden name="amount_'.$x.'" value="'.$price.'">
<input type=hidden name="quantity_'.$x.'" value="'.$each_item['quantity'].'">';
// dynamic cart item display
$cartOutput.="<tr align=center>
<td width=5%><font color='#999999'>".substr($each_item['id'],0,7)."</font></td>
<td width=25%><font color='#999999'>".$product_name."</font></td>
<td width=40% valign=top><font color='#999999'>Foaming Bath Butter 8oz: ".$scent."<br> Body Scrub 8oz: " .$scent2."<br>Body Mist 150mL: ".$scent3."<br>Hand Cream 60mL: ".$scent4."</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=".$each_item['quantity'].">
<input type=hidden name='item_to_adjust' value='".$item_id."'/>
<input type=hidden name='name' value='".$product_name."'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$".$price.".00</font></td>
<td width=10%><font color='#999999'>$".$subtotal.".00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>";
$i++;
} // end if statement to see if cart is empty
break;
// if it is a $75 gift box
case "12":
$scent_id=substr($each_item['scent'],0,4);
$scent2_id=substr($each_item['scent'],4,4);
$scent3_id=substr($each_item['scent'],8,4);
$scent4_id=substr($each_item['scent'],12,4);
$scent5_id=substr($each_item['scent'],16,4);
$scent6_id=substr($each_item['scent'],20,4);
// Get product name and price
$sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1");
while ($row=mysql_fetch_array($sql)) {
$product_name=$row["productName"];
$price=$row["productPrice"];
}
// get Bath Butter Scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent=$row2['scentName'];
}
// get Body Scrub scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent2_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent2=$row2['scentName'];
}
// get Body Mist scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent3_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent3=$row2['scentName'];
}
// get Elite Hand Cream 120mL scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent4_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent4=$row2['scentName'];
}
// get Bath Salt 8oz scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent5_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent5=$row2['scentName'];
}
// get Massage Oil 50mL scent
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent6_id' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent6=$row2['scentName'];
}
$subtotal=$price*$each_item['quantity'];
$total=$subtotal + $total;
if(isset ($_SESSION["cart_array"] )) {
// dynamic checkout button assembly
$x=$i+1;
$pp_checkout_btn.='<input type=hidden name="item_name_'.$x.'" value="'.$product_name.'<br>FBB 8oz: '.$scent_id.', Scrub 8oz: '.$scent2_id.', Mist 150mL: '.$scent3_id.', Elite 120mL: '.$scent4_id.', Salt 8oz: '.$scent5_id.', Massage 50mL: '.$scent6_id.'<br>">
<input type=hidden name="amount_'.$x.'" value="'.$price.'">
<input type=hidden name="quantity_'.$x.'" value="'.$each_item['quantity'].'">';
// dynamic cart item display
$cartOutput.="<tr align=center>
<td width=5%><font color='#999999'>".substr($each_item['id'],0,7)."</font></td>
<td width=25%><font color='#999999'>".$product_name."</font></td>
<td width=40% valign=top><font color='#999999'>Foaming Bath Butter 8oz: ".$scent."<br> Body Scrub 8oz: " .$scent2."<br>Body Mist 150mL: ".$scent3."<br>Elite Hand Cream 120mL: ".$scent4."<br>Bath Salt 8oz: " .$scent5."<br>Massage Oil 50mL: ".$scent6."</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=".$each_item['quantity'].">
<input type=hidden name='item_to_adjust' value='".$item_id."'/>
<input type=hidden name='name' value='".$product_name."'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$".$price.".00</font></td>
<td width=10%><font color='#999999'>$".$subtotal.".00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>";
$i++;
} // end if statement to see if cart is empty
break;
// if it is a clearance/sale item
case "13":
$scent=substr($each_item['scent'],0,4);
$clearId=substr($each_item['id'],2,4);
// Get product name and price
$sql=mysql_query("SELECT * FROM clearance WHERE productId='$clearId' LIMIT 1");
while ($row=mysql_fetch_array($sql)) {
$clearId=$row['productId'];
$product_name=$row["productName"];
$price=$row["price"];
$stock=$row["stock"];
}
# get product scent name
$sql2= "SELECT productscents.scentName FROM productscents WHERE productscents.scentId = '$scent'";
$result2 = mysql_query($sql2);
$row2 = mysql_fetch_array($result2);
$scent=$row2['scentName'];
if(isset ($_SESSION["cart_array"] )) {
if($each_item['quantity']>$stock) {
$each_item['quantity']=$stock;
}
$subtotal=$price*$each_item['quantity'];
$total=$subtotal + $total;
// dynamic checkout button assembly
$x=$i+1;
$pp_checkout_btn.='<input type=hidden name="item_name_'.$x.'" value="'.$scent.' '.$product_name.'">
<input type=hidden name="amount_'.$x.'" value="'.$price.'">
<input type=hidden name="quantity_'.$x.'" value="'.$each_item['quantity'].'">';
// dynamic cart item display
$cartOutput.="<tr align=center>
<td width=5%><font color='#999999'>".$each_item['id']."</font></td>
<td width=25%><font color='#999999'>".$product_name."<br>* CLEARANCE * </font></td>
<td width=40%><font color='#999999'>".$scent."</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=".$each_item['quantity'].">
<input type=hidden name='item_to_adjust' value='".$item_id."'/>
<input type=hidden name='name' value='".$product_name."'/>
<input type=hidden name='scent' value='".$scent."'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$".$price.".00</font></td>
<td width=10%><font color='#999999'>$".$subtotal.".00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>";
$i++;
} // end if statement to see if cart is empty
/*
// update database Stock Quantity
if ($each_item['quantity'] !=0) {
$updateQuantity=$stock-$each_item['quantity'];
mysql_select_db('CopperCreek');
mysql_query("UPDATE clearance SET stock = '$updateQuantity' WHERE productId = '$clearId'");
}
if ($each_item['quantity'] ==0) {
$updateQuantity=$each_item['quantity']+$stock;
mysql_select_db('CopperCreek');
mysql_query("UPDATE clearance SET stock = '$updateQuantity' WHERE productId = '$clearId'");
}
*/
break;
// if it is not a gift box or sale/clearance item
default :
$scent=substr($each_item['scent'],0,4);
// Get product name and price
$sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1");
while ($row=mysql_fetch_array($sql)) {
$product_name=$row["productName"];
$price=$row["productPrice"];
}
// get scent for regular product
$sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent' LIMIT 1");
while ($row2=mysql_fetch_array($sql2)) {
$scent=$row2['scentName'];
}
$subtotal=$price*$each_item['quantity'];
$total=$subtotal + $total;
if(isset ($_SESSION["cart_array"] )) {
// dynamic checkout button assembly
$x=$i+1;
$pp_checkout_btn.='<input type=hidden name="item_name_'.$x.'" value="'.$scent.' '.$product_name.'">
<input type=hidden name="amount_'.$x.'" value="'.$price.'">
<input type=hidden name="quantity_'.$x.'" value="'.$each_item['quantity'].'">';
// dynamic cart item display
$cartOutput.="<tr align=center>
<td width=5%><font color='#999999'>".substr($each_item['id'],0,7)."</font></td>
<td width=25%><font color='#999999'>".$product_name."</font></td>
<td width=40%><font color='#999999'>".$scent."</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=".$each_item['quantity'].">
<input type=hidden name='item_to_adjust' value='".$item_id."'/>
<input type=hidden name='name' value='".$product_name."'/>
<input type=hidden name='scent' value='".$scent."'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$".$price.".00</font></td>
<td width=10%><font color='#999999'>$".$subtotal.".00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>";
$i++;
} // end if statement to see if cart is empty
break;
} // end switch
} // end foreach that goes through each item in the cart
// Finish the Paypal Checkout Button
$pp_checkout_btn .='
<input type=hidden name="return" value="success.php">
<input type=hidden name="rm" value="2">
<input type=hidden name="cbt" value="Return to Store">
<input type=hidden name="cancel_return" value="http://www.coppercreekbathandbody.ca/cancel.php">
<input type=hidden name="currency_code" value="CAD">
<a href=# onclick=submit();><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="center" border=0;"></a></form>';
}
?>
<html>
<script type="text/javascript" src="./js/functions.js"></script>
<body background="#1d1d1d">
<div id="wrapper">
<div id="main">
<table border=0 width=70% cellspacing=0 cellpadding=5 id="carttable" ><form>
<tr>
<td colspan=6 align=center>
<img src="./images/copperCreekLogo.gif">
</td>
</tr>
<tr align=center>
<td width=5%><strong><font color="#cbb659">ID</font></strong></td>
<td width=25%><b><font color="#cbb659">Product Name</font></b></td>
<td width=40%><b><font color="#cbb659">Scent</font></b></td>
<td width=5%><b><font color="#cbb659">Quantity</font></b></td>
<td width=5%><b><font color="#cbb659">Price</font></b></td>
<td width=10%><b><font color="#cbb659">Total Cost</font></b></td>
</tr>
<tr>
<?php echo $cartOutput;?>
</tr>
<tr>
<td colspan=3 align=center><font size=-1 color=#999999>***Update quantity to 0, to remove the item from your cart***</font></td>
<td colspan=2 align=right><font face=arial color="#999999">Total Price:</font></td>
<td align=center><?php echo "$".$total.".00";?></td>
</tr>
<tr>
<td colspan=3>
<center>
<a href="cart.php?cmd=emptycart"><font face=arial color="#cbb659">Empty Cart</a>
</font></center>
</td>
<td colspan=3 valign=center><br>
<center><font face=arial color="#999999"><?php echo $pp_checkout_btn; ?></font></center>
</td>
</tr>
</form>
</table>
</div>
<div id="sidebar">
<?php require ("menu.html");?>
</div>
</div> <!-- End wrapper class -->
</body>
</html>
Re: Can't adjust qty or remove first item in the cart
Posted: Thu Mar 24, 2011 11:33 am
by Jonah Bron

Could you post just the HTML? I mean open the site, put in a few products, and then view source.
Re: Can't adjust qty or remove first item in the cart
Posted: Thu Mar 24, 2011 11:17 pm
by mrzebra
here is the html source code from the cart page after i added some items. You can also view the webpage at coppercreekbathandbody.ca
Code: Select all
<html>
<script type="text/javascript" src="./js/functions.js"></script>
<body background="#1d1d1d">
<div id="wrapper">
<div id="main">
<table border=0 width=70% cellspacing=0 cellpadding=5 id="carttable" ><form>
<tr>
<td colspan=6 align=center>
<img src="./images/copperCreekLogo.gif">
</td>
</tr>
<tr align=center>
<td width=5%><strong><font color="#cbb659">ID</font></strong></td>
<td width=25%><b><font color="#cbb659">Product Name</font></b></td>
<td width=40%><b><font color="#cbb659">Scent</font></b></td>
<td width=5%><b><font color="#cbb659">Quantity</font></b></td>
<td width=5%><b><font color="#cbb659">Price</font></b></td>
<td width=10%><b><font color="#cbb659">Total Cost</font></b></td>
</tr>
<tr>
<tr align=center>
<td width=5%><font color='#999999'>20032</font></td>
<td width=25%><font color='#999999'>Hand Cream 60mL</font></td>
<td width=40%><font color='#999999'>Acia Mango Passion</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=1>
<input type=hidden name='item_to_adjust' value='20032'/>
<input type=hidden name='name' value='Hand Cream 60mL'/>
<input type=hidden name='scent' value='Acia Mango Passion'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$10.00</font></td>
<td width=10%><font color='#999999'>$10.00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr><tr align=center>
<td width=5%><font color='#999999'>40032</font></td>
<td width=25%><font color='#999999'>Body Mist 150mL</font></td>
<td width=40%><font color='#999999'>Acia Mango Passion</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=1>
<input type=hidden name='item_to_adjust' value='40032'/>
<input type=hidden name='name' value='Body Mist 150mL'/>
<input type=hidden name='scent' value='Acia Mango Passion'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$9.00</font></td>
<td width=10%><font color='#999999'>$9.00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr><tr align=center>
<td width=5%><font color='#999999'>80014</font></td>
<td width=25%><font color='#999999'>Body Scrubs 12oz</font></td>
<td width=40%><font color='#999999'>Blue Raspberry</font></td>
<td valign=center width=5%><font color='#999999'><form action=cart.php method=post>
<input class=box name=quantity type=text size=1 width=3 maxlength=3 onKeyPress='return check_qty(event);' value=1>
<input type=hidden name='item_to_adjust' value='80014'/>
<input type=hidden name='name' value='Body Scrubs 12oz'/>
<input type=hidden name='scent' value='Blue Raspberry'/>
<br><font color='#999999' size='-1'><a href=# onClick='submit()'>Update</a><br>
</font></td>
<td width=5%><font color='#999999'>$12.00</font></td>
<td width=10%><font color='#999999'>$12.00</font></td>
</tr></form>
<tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>
</tr>
<tr>
<td colspan=3 align=center><font size=-1 color=#999999>***Update quantity to 0, to remove the item from your cart***</font></td>
<td colspan=2 align=right><font face=arial color="#999999">Total Price:</font></td>
<td align=center>$31.00</td>
</tr>
<tr>
<td colspan=3>
<center>
<a href="cart.php?cmd=emptycart"><font face=arial color="#cbb659">Empty Cart</a>
</font></center>
</td>
<td colspan=3 valign=center><br>
<center><font face=arial color="#999999"><form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="shopping_url" value="http://www.coppercreekbathandbody.ca/mainProducts.php">
<input type="hidden" name="page_style" value="copperCreek">
<input type="hidden" name="cs" value="0">
<input type=hidden name="cmd" value="_cart">
<input type=hidden name="upload" value="1">
<input type=hidden name="business" value="coppercreekbathandbody@yahoo.ca"><input type=hidden name="item_name_1" value="Acia Mango Passion Hand Cream 60mL">
<input type=hidden name="amount_1" value="10">
<input type=hidden name="quantity_1" value="1"><input type=hidden name="item_name_2" value="Acia Mango Passion Body Mist 150mL">
<input type=hidden name="amount_2" value="9">
<input type=hidden name="quantity_2" value="1"><input type=hidden name="item_name_3" value="Blue Raspberry Body Scrubs 12oz">
<input type=hidden name="amount_3" value="12">
<input type=hidden name="quantity_3" value="1">
<input type=hidden name="return" value="success.php">
<input type=hidden name="rm" value="2">
<input type=hidden name="cbt" value="Return to Store">
<input type=hidden name="cancel_return" value="http://www.coppercreekbathandbody.ca/cancel.php">
<input type=hidden name="currency_code" value="CAD">
<a href=# onclick=submit();><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="center" border=0;"></a></form></font></center>
</td>
</tr>
</form>
</table>
</div>
<div id="sidebar">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="./css/navigationStyles.css"/>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/sliding_effect.js"></script>
</head>
<body background="#1d1d1d">
<div id="navigation-block">
<img src="./images/background.jpg" id="hide" />
<ul id="sliding-navigation">
<li class="sliding-element"><a href="home.php">Home</a></li>
<li class="sliding-element"><a href="mainProducts.php">Main Product Page</a></li>
<li class="sliding-element"><a href="handCream60.php">Hand Creams 60mL</a></li>
<li class="sliding-element"><a href="handCream100.php">Hand Creams 100mL</a></li>
<li class="sliding-element"><a href="eliteHandCream.php">Elite Hand Creams</a></li>
<li class="sliding-element"><a href="bathSalt.php">Bath Salts</a></li>
<li class="sliding-element"><a href="bodyMist.php">Body Mists</a></li>
<li class="sliding-element"><a href="fizzyBathSalt.php">Fizzy Bath Salts</a></li>
<li class="sliding-element"><a href="bodyScrub.php">Body Scrubs</a></li>
<li class="sliding-element"><a href="massageOil.php">Massage Oils</a></li>
<li class="sliding-element"><a href="foamingBathButter.php">Foaming Bath Butter</a></li>
<li class="sliding-element"><a href="bathSoak.php">Bath Soaks</a></li>
<li class="sliding-element"><a href="giftBox50.php">$50 Gift Box</a></li>
<li class="sliding-element"><a href="giftBox75.php">$75 Gift Box</a></li>
<li class="sliding-element"><a href="clearance.php">Clearance Items</a></li>
<li class="sliding-element"><a href="instructions.php">Product Instructions</a></li>
<li class="sliding-element"><a href="shipping.php">Payments & Shipping</a></li>
<li class="sliding-element"><a href="contact.php">Contact Us</a></li>
<li class="sliding-element"><a href="comments.php">Comments & Reviews</a></li>
<li class="sliding-element"><a href="http://usuireikisaskatoon.webs.com">Reiki</a></li>
</ul>
</div>
</body>
</html>
</div>
</div> <!-- End wrapper class -->
</body>
</html>
Re: Can't adjust qty or remove first item in the cart
Posted: Fri Mar 25, 2011 11:06 am
by Jonah Bron
Looks like you update with Javascript. First of all, that's not a good idea. For something vital like a shopping cart, it should work without JS. Second, could we see the JS?
Re: Can't adjust qty or remove first item in the cart
Posted: Fri Mar 25, 2011 6:30 pm
by mrzebra
The only javascript function I use for the cart is to make sure the qty entered is a valid number, not a letter or negative number. I pass the javascript variables in the url and use the $_GET to retrieve the values passed.
Re: Can't adjust qty or remove first item in the cart
Posted: Fri Mar 25, 2011 6:58 pm
by Jonah Bron
But what about submit()? That's the part I need to see.
Re: Can't adjust qty or remove first item in the cart
Posted: Sat Mar 26, 2011 1:35 am
by mrzebra
I don't have a function written for submit. I'm just using the default submit function....?? Maybe I shouldn't be using submit???
So I removed the onClick="submit()" for the "update" qty in the cart and it still won't change the quantity of the first item in the cart. All the other items still change. It's strange how the first item won't remove or the qty won't get updated.