/** * Allows access to the cart from anywhere in code. * @return ShoppingCart Object */ public static function singleton() { if (!self::$singletoncart) { self::$singletoncart = new ShoppingCart(); } return self::$singletoncart; }
/** * Clears the cart contents completely by removing the orderID from session, and * thus creating a new cart on next request. * @return Boolean */ public function clear() { //we keep this here so that a flush can be added... set_time_limit(1200); self::$singletoncart = null; $this->order = null; $this->messages = array(); foreach (self::$session_variable_names as $name) { $sessionVariableName = $this->sessionVariableName($name); Session::set($sessionVariableName, null); Session::clear($sessionVariableName); Session::save(); } $memberID = Intval(Member::currentUserID()); if ($memberID) { $orders = Order::get()->filter(array("MemberID" => $memberID)); if ($orders && $orders->count()) { foreach ($orders as $order) { if (!$order->IsSubmitted()) { $order->delete(); } } } } return true; }