Hi Guys…
I am setting a shopping cart and it works OK with BUY NOW buttons and adds the product to the cart one at a time.
However, I want to select a few items, via checkboxes, and pass them to the cart.php all at the same time. The shopping cart has facility to change the quantities and update the cart.
This is a chopped down version of the sending code:
$main_content .= "<form action='cart/cart.php?action=add&id=$id' method='get' target='new'>";
if($color==1){
$main_content .= "<tr bgcolor='#ffcc99'>";
// ORDERS 1
$main_content .= "<td valign='top'>$product <font color=#ff0000><b>$comments</b></font></td>";
$main_content .= "<td valign='top'>$packquantity</td>\
";
$main_content .= "<td valign='top'>£$trade</td>\
";
$main_content .= "<td valign='top'><input type='checkbox' name='id' value='$id'>\
";
$main_content .= "</tr>\
";
$main_content .= "<input type='submit' value='Place Order'>";
$main_content .= " <input type='reset' value='Clear'>";
$main_content .= "</form></form></td></tr></table>\
";
The receiving code in my cart.php file is:
$cart = $_SESSION['cart'];
$action = $_GET['action'];
switch ($action) {
case 'add':
if ($cart) {
$cart .= ','.$_GET['id'];
} else {
$cart = $_GET['id'];
}
header("Location: cart.php");
break;
I think that the receiving code is wrong. It works OK for the BUY NOW button, one at a time, but it doesn’t work for multiple additions.
Can anybody help ???
Thanks,
John C