wrighty59uk
01-10-2007, 08:55 AM
Hi, Not sure if ive posted this in the right place, sorry in advance if its not in the right place. I currently have a website that was designed for me, the site works great for me but i want to add something to the personal cart page. the code for the page i want to change is
<?php
include "include/config.inc.php";
include "include/functions.inc.php";
db();
$breadcrumbs=array('index.php'=>'home','personal_cart.php'=>'shopping basket');
$leather_table=array();
$sql="SELECT * FROM leather ORDER BY leather_sequence_id";
if (!($result=mysql_query($sql))) DBerror();
while ($row=mysql_fetch_assoc($result)) $leather_table[$row['ID']]=$row;
$wood_table=array();
$sql="SELECT * FROM wood ORDER BY wood_sequence_id";
if (!($result=mysql_query($sql))) DBerror();
while ($row=mysql_fetch_assoc($result)) $wood_table[$row['ID']]=$row;
@$cart=unserialize(stripslashes($_COOKIE['cart']));
if (!$cart) $cart=array();
foreach (array('destination_country','collect_furniture') as $cn) {
if (isset($_POST[$cn])) {
setcookie($cn,$_POST[$cn]);
$_COOKIE[$cn]=$_POST[$cn];
}
}
switch (@$_REQUEST['action']) {
case 'add':
$item=&$cart[$_REQUEST['id']];
$item['leather']=$_REQUEST['leather'];
$item['wood']=$_REQUEST['wood'];
$item['qty']=array();
for ($i=1;$i<=8;$i++) {
$item['qty'][$i]=(int)@$_REQUEST["qty-$i"];
}
unset($item);
break;
case 'change':
$ids=array_keys($cart);
foreach ($ids as $id) {
$data=&$cart[$id];
for ($i=1;$i<=8;$i++) {
$data['qty'][$i]=(int)@$_REQUEST["qty-$id-$i"];
}
unset($data);
}
break;
}
// remove:
$ids=array_keys($cart);
foreach ($ids as $id) {
$data=&$cart[$id];
for ($i=1;$i<=6;$i++) {
if (isset($_REQUEST["remove-$id-$i"])) $data['qty'][$i]=0;
}
unset($data);
}
setcookie('cart',serialize($cart));
include "include/header.inc.php";
echo "<h1>YOUR BASKET</h1>\n";
//if ($cart=="") {
$cart_empty=true;
$occasional=false;
$not_occasional=false;
foreach ($cart as $id=>$data) {
foreach ($data['qty'] as $i=>$qty) {
if (!$qty) continue;
$cart_empty=false;
}
}
if ($cart_empty) {
echo ("<br>
<font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><center><b>Your personal cart is empty.<br><br>
<a href=\"javascript: window.history.go(-1)\">Back</a></B></center></font>");
} else {
// echo "here";
echo "<div class='cart'>";
echo "<center>";
echo "<form action=\"".basename($PHP_SELF)."\" method=\"post\">";
$cart_total=$delivery_charge_total=0;
foreach ($cart as $id=>$data) {
foreach ($data['qty'] as $i=>$qty) {
if (!$qty) continue;
echo show_cart_item($id,$data,$i,TRUE);
}
}
//echo "occasional 2 ".$occasional."<br>";
echo show_total_line(TRUE);
echo "<br><br><b>Please choose Country of destination and click UPDATE below: </b> ";
dropdown_display(
$countries,
@$_COOKIE['destination_country'],
" name='destination_country'"
);
echo "<br><br><br>";
echo ("<br>
<table width=450 border=0 cellspacing=0><tr><td align=right width=300 valign=top>
<input type=\"Hidden\" name=\"action\" value=\"change\">
<input type=\"Submit\" value=\"Update\" class=\"submit \"> </td></form><form action=\"complete_order.php\" method=\"GET\"><td align=right><input type=\"Submit\" value=\"CHECKOUT\" class=\"submit \">
</tr></tr></form>
<tr><Td colspan=2> <br><br><br><br>
</TD></tr>
</table>
");
echo "</center>";
echo "</div>";
} // ENd of cart=''
include "include/footer.inc.php";
?>
the address for my site is www.classic-designs.co.uk
in the personal cart i want to add the option for a cutsomer to purchase a cleaning kit. and preferably have some sort of link so it pops up a window that shows them a picture of the cleanng kit and some info about it
hope ive explained everything above, if nothing makes sence please let me know and i will try and re-explain
Thanxs in advance for any help
<?php
include "include/config.inc.php";
include "include/functions.inc.php";
db();
$breadcrumbs=array('index.php'=>'home','personal_cart.php'=>'shopping basket');
$leather_table=array();
$sql="SELECT * FROM leather ORDER BY leather_sequence_id";
if (!($result=mysql_query($sql))) DBerror();
while ($row=mysql_fetch_assoc($result)) $leather_table[$row['ID']]=$row;
$wood_table=array();
$sql="SELECT * FROM wood ORDER BY wood_sequence_id";
if (!($result=mysql_query($sql))) DBerror();
while ($row=mysql_fetch_assoc($result)) $wood_table[$row['ID']]=$row;
@$cart=unserialize(stripslashes($_COOKIE['cart']));
if (!$cart) $cart=array();
foreach (array('destination_country','collect_furniture') as $cn) {
if (isset($_POST[$cn])) {
setcookie($cn,$_POST[$cn]);
$_COOKIE[$cn]=$_POST[$cn];
}
}
switch (@$_REQUEST['action']) {
case 'add':
$item=&$cart[$_REQUEST['id']];
$item['leather']=$_REQUEST['leather'];
$item['wood']=$_REQUEST['wood'];
$item['qty']=array();
for ($i=1;$i<=8;$i++) {
$item['qty'][$i]=(int)@$_REQUEST["qty-$i"];
}
unset($item);
break;
case 'change':
$ids=array_keys($cart);
foreach ($ids as $id) {
$data=&$cart[$id];
for ($i=1;$i<=8;$i++) {
$data['qty'][$i]=(int)@$_REQUEST["qty-$id-$i"];
}
unset($data);
}
break;
}
// remove:
$ids=array_keys($cart);
foreach ($ids as $id) {
$data=&$cart[$id];
for ($i=1;$i<=6;$i++) {
if (isset($_REQUEST["remove-$id-$i"])) $data['qty'][$i]=0;
}
unset($data);
}
setcookie('cart',serialize($cart));
include "include/header.inc.php";
echo "<h1>YOUR BASKET</h1>\n";
//if ($cart=="") {
$cart_empty=true;
$occasional=false;
$not_occasional=false;
foreach ($cart as $id=>$data) {
foreach ($data['qty'] as $i=>$qty) {
if (!$qty) continue;
$cart_empty=false;
}
}
if ($cart_empty) {
echo ("<br>
<font size=\"2\" face=\"Arial, Helvetica, sans-serif\"><center><b>Your personal cart is empty.<br><br>
<a href=\"javascript: window.history.go(-1)\">Back</a></B></center></font>");
} else {
// echo "here";
echo "<div class='cart'>";
echo "<center>";
echo "<form action=\"".basename($PHP_SELF)."\" method=\"post\">";
$cart_total=$delivery_charge_total=0;
foreach ($cart as $id=>$data) {
foreach ($data['qty'] as $i=>$qty) {
if (!$qty) continue;
echo show_cart_item($id,$data,$i,TRUE);
}
}
//echo "occasional 2 ".$occasional."<br>";
echo show_total_line(TRUE);
echo "<br><br><b>Please choose Country of destination and click UPDATE below: </b> ";
dropdown_display(
$countries,
@$_COOKIE['destination_country'],
" name='destination_country'"
);
echo "<br><br><br>";
echo ("<br>
<table width=450 border=0 cellspacing=0><tr><td align=right width=300 valign=top>
<input type=\"Hidden\" name=\"action\" value=\"change\">
<input type=\"Submit\" value=\"Update\" class=\"submit \"> </td></form><form action=\"complete_order.php\" method=\"GET\"><td align=right><input type=\"Submit\" value=\"CHECKOUT\" class=\"submit \">
</tr></tr></form>
<tr><Td colspan=2> <br><br><br><br>
</TD></tr>
</table>
");
echo "</center>";
echo "</div>";
} // ENd of cart=''
include "include/footer.inc.php";
?>
the address for my site is www.classic-designs.co.uk
in the personal cart i want to add the option for a cutsomer to purchase a cleaning kit. and preferably have some sort of link so it pops up a window that shows them a picture of the cleanng kit and some info about it
hope ive explained everything above, if nothing makes sence please let me know and i will try and re-explain
Thanxs in advance for any help