* @version 1.0 * * Example of use: --------------------------------------------------------------------- ... --------------------------------------------------------------------- */ class Cart { // Namespace of this instance. var $_ns; // Configuration parameters for this object. var $_params = array( ); /** * Cart constructor. */ function Cart($namespace='') { $app =& App::getInstance(); $this->_ns = $namespace; // Initialize. if (!isset($_SESSION['_cart'][$this->_ns])) { $this->clear(); } } /** * Set the params of this object. * * @param array $params Array of param keys and values to set. */ function setParam($params=null) { if (isset($params) && is_array($params)) { // Merge new parameters with old overriding only those passed. $this->_params = array_merge($this->_params, $params); } } /** * Return the value of a parameter, if it exists. * * @access public * @param string $param Which parameter to return. * @return mixed Configured parameter value. */ function getParam($param) { $app =& App::getInstance(); if (isset($this->_params[$param])) { return $this->_params[$param]; } else { $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); return null; } } /* * * * @access public * @param * @return * @author Quinn Comendant * @version 1.0 * @since 11 Mar 2008 18:59:37 */ function add($item_id, $quantity=1) { } /* * * * @access public * @param * @return * @author Quinn Comendant * @version 1.0 * @since 11 Mar 2008 18:59:48 */ function remove($item_id) { } /* * * * @access public * @param * @return * @author Quinn Comendant * @version 1.0 * @since 11 Mar 2008 18:59:55 */ function getList() { } /* * * * @access public * @param * @return * @author Quinn Comendant * @version 1.0 * @since 11 Mar 2008 19:00:12 */ function getTotal() { } /** * Resets the $_SESSION cart array. This should be executed with the same consideration * as $auth->clear(), such as when logging out. */ function clear() { $_SESSION['_cart'][$this->_ns] = array( 'items' => array(), ); } } ?>