second draft of cart class
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 16 Oct 2007 06:53:38 +0000 (06:53 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Tue, 16 Oct 2007 06:53:38 +0000 (06:53 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@55 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

www/inc/cart.php

index 41c8143..9b741e3 100644 (file)
@@ -30,10 +30,12 @@ class CartTicket
        public function changeAmount($amt)
        {
                global $db;
-               if($amd<=0){
+               if($amt<=0){
                        $db->deleteRows("cart_ticket","cartid='".addslashes($this->cartid)."' and eventid=".$this->eventid);
+                       $this->amount=0;
                }else{
                        $db->update("cart_ticket",array("amount"=>($amt+0)),"cartid='".addslashes($this->cartid)."' and eventid=".$this->eventid);
+                       $this->amount=$amt;
                }
        }
        
@@ -42,6 +44,18 @@ class CartTicket
        {
                return new Event($this->eventid);
        }
+       
+       /**return the eventID*/
+       public function getEventId()
+       {
+               return $this->eventid;
+       }
+       
+       /**return the current amount*/
+       public function getAmount()
+       {
+               return $this->amount;
+       }
 };
 
 /**this class represents a shopping cart*/
@@ -82,6 +96,12 @@ class Cart
                return $this->cartid!==false;
        }
        
+       /**returns the ID of this cart, returns false if the cart is not valid*/
+       public function getCartId()
+       {
+               return $this->cartid;
+       }
+       
        /**use this to get all existing tickets in this cart, then manipulate the tickets directly*/
        public function getTickets()
        {