Hope someone can help with this.
I've basically inherited a site with a shopping cart, which has a couple of optional extras on products - paintwork and cushions.
I've been asked to add in a third optional extra, glasstops.
At the moment there is a little if... else... loop which determines wether or not the relevant pages for those extras are displayed.
So, at the moment it goes > products.php > paintwork.php (if the paintwork field is not empty) > accessories.php (if the accessories field is not empty).
That code looks like :
foreach ($_SESSION["basket"]["items"] as $key => $value) {
if ($value["product"] == $_POST["id"]) {
//$sql = "SELECT `cushions` FROM `products` WHERE `id` = '" . $value["product"] . "'";
//$result = mysql_query($sql) or die("Query failed : $sql at line " . __line__);
if (!@empty($row["paintwork"])) {
$redirect = "paintwork.php?id={$key}";
} elseif (!@empty($row["cushions"])) {
$redirect = "shopping_cart.php";
} else {
$redirect = "accessories.php?id={$key}";
}
header("location: {$redirect}");
exit;
}
I've created a glasstop.php page, and changed that to :
foreach ($_SESSION["basket"]["items"] as $key => $value) {
if ($value["product"] == $_POST["id"]) {
//$sql = "SELECT `cushions` FROM `products` WHERE `id` = '" . $value["product"] . "'";
//$result = mysql_query($sql) or die("Query failed : $sql at line " . __line__);
if (!@empty($row["glasstop"])) {
$redirect = "glasstop.php?id={$key}";
} elseif (!@empty($row["cushions"])) {
$redirect = "shopping_cart.php";
} else {
$redirect = "accessories.php?id={$key}";
}
header("location: {$redirect}");
exit;
}
which is fine, but haven't quite been able to get it to work with all three - the closest I've got without errors is :
foreach ($_SESSION["basket"]["items"] as $key => $value) {
if ($value["product"] == $_POST["id"]) {
//$sql = "SELECT `cushions` FROM `products` WHERE `id` = '" . $value["product"] . "'";
//$result = mysql_query($sql) or die("Query failed : $sql at line " . __line__);
if (!@empty($row["paintwork"])) {
$redirect = "paintwork.php?id={$key}";
} elseif (!@empty($row["glasstop"])) {
$redirect = "glasstop.php?id={$key}";
}
elseif (!@empty($row["cushions"])) {
$redirect = "shopping_cart.php";
} else {
$redirect = "accessories.php?id={$key}";
}
header("location: {$redirect}");
exit;
}
If anyone could help out with this that would be much appreciated.
Thanks.