Page 1 of 1

issue with minusing price

Posted: Mon Sep 27, 2010 10:36 am
by aravona
On a site I'm working on there is a shopping cart. I need to get some additional prices to go into the database, but only on some products.

The price goes in fine using the following:

Code: Select all

if($pack == 'Essentials A0200') {
		$totalPrice = $totalPrice + '24.95';
		}
		
    if($class->isThere("sessionID","tempcart"," sessionID='".$session_id."'")){
	$tempCartID=$class->returnName("tempCartID","tempcart","sessionID",$session_id,'');
	$query="UPDATE tempcart SET totalPrice=totalPrice+$totalPrice,
		totalQty=totalQty+$totalQty
	WHERE sessionID='".$session_id."'";
That being my addition for $pack and the original coding. There are about 20-30 packs.

The problem is if I remove the item form the cart this additional fee stays (so where it should be £0 it says £24.95)

The following is the code which deletes the item from the database:

Code: Select all

	if(@$_REQUEST['delID']!=''){
		$delID=$_REQUEST['delID'];
		$query="SELECT * 
				FROM tempcartdetail 
				WHERE tempCartDetailID='".$delID."'";
		$result=$class->ResultSet($query);
		if($class->NumRows($result)>0){
			$row=$class->FetchObject($result);
			$query="UPDATE tempcart SET totalPrice=totalPrice-$row->price*$row->qty,
										totalQty=totalQty-$row->qty
					WHERE tempCartID='".$row->tempCartID."'";
			mysql_query($query);
			
			if($row2->pack == 'Essentials A0200') {
			$query="UPDATE tempcart SET totalPrice=totalPrice-$row->price-'24.95'
					WHERE tempCartID='".$row->tempCartID."'";
			mysql_query($query);
			}
			
			$query="DELETE FROM tempcartdetail2 WHERE tempCartDetailID='".$delID."'";
			mysql_query($query);
			
			$query="DELETE FROM tempcartdetail WHERE tempCartDetailID='".$delID."'";
			mysql_query($query);
					
			header('location: '.CART);
			exit(0);		
			
		}
You can see the part I added in to remove the extra 24.95 but, it doesnt work. Can anyone point me in the right direction?

Regards,

Aravona

Re: issue with minusing price

Posted: Mon Sep 27, 2010 10:41 pm
by Jonah Bron
What doesn't work? Do you get an error, or is the item just still in the database?

Re: issue with minusing price

Posted: Tue Sep 28, 2010 2:02 am
by aravona
The problem is the 24.95 added for certain products wont remove with the second bit of code.

So the shopping cart is empty but still has 24.95 in it!

Aravona