issue with minusing price

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

issue with minusing price

Post 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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: issue with minusing price

Post by Jonah Bron »

What doesn't work? Do you get an error, or is the item just still in the database?
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: issue with minusing price

Post 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
Post Reply