Changeset 611 for trunk/lib/Cart.inc.php
- Timestamp:
- Aug 24, 2017 4:27:34 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Cart.inc.php
r502 r611 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 28 28 * @author Quinn Comendant <quinn@strangecode.com> 29 29 * @version 1.0 30 * 30 * 31 31 * Example of use: 32 32 --------------------------------------------------------------------- … … 86 86 87 87 $this->_ns = $namespace; 88 88 89 89 // Initialize. 90 90 if (!isset($_SESSION['_cart'][$this->_ns])) { … … 116 116 { 117 117 $app =& App::getInstance(); 118 118 119 119 if (array_key_exists($param, $this->_params)) { 120 120 return $this->_params[$param]; … … 141 141 { 142 142 $app =& App::getInstance(); 143 143 144 144 // Include any previously added items in the total quantity. 145 145 $quantity += isset($_SESSION['_cart'][$this->_ns]['items'][$item_id]) ? $_SESSION['_cart'][$this->_ns]['items'][$item_id]['quantity'] : 0; 146 146 147 147 // Add item with adjusted quantity and merge in additional specs. 148 148 $_SESSION['_cart'][$this->_ns]['items'][$item_id] = array_merge($specs, array( … … 151 151 'extended_price' => $quantity * $price, 152 152 )); 153 153 154 154 $app->logMsg(sprintf('Added %s %s to cart (%s)', $quantity, $item_id, truncate(getDump($specs, true), 128, 'end')), LOG_DEBUG, __FILE__, __LINE__); 155 155 156 156 return $quantity; 157 157 } 158 158 159 159 /* 160 160 * Set the absolute quantity value of a specified item in a cart. 161 161 * 162 162 * @access public 163 * @param 164 * @return 163 * @param 164 * @return 165 165 * @author Quinn Comendant <quinn@strangecode.com> 166 166 * @version 1.0 … … 185 185 } 186 186 } 187 187 188 188 /* 189 189 * Set the absolute price value of a specified item in a cart. 190 190 * 191 191 * @access public 192 * @param 193 * @return 192 * @param 193 * @return 194 194 * @author Quinn Comendant <quinn@strangecode.com> 195 195 * @version 1.0 … … 209 209 } 210 210 } 211 211 212 212 /* 213 213 * Remove an item from the cart. … … 222 222 { 223 223 $app =& App::getInstance(); 224 224 225 225 if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id])) { 226 226 unset($_SESSION['_cart'][$this->_ns]['items'][$item_id]); … … 231 231 } 232 232 } 233 233 234 234 /* 235 235 * Return the value matching key for a specified item. … … 250 250 return false; 251 251 } 252 252 253 253 /* 254 254 * Return an array of the items in cart. … … 264 264 return $_SESSION['_cart'][$this->_ns]['items']; 265 265 } 266 266 267 267 /* 268 268 * Return the sum of the numeric values stored under the specified key for cart items. … … 299 299 break; 300 300 } 301 301 302 302 return $sum; 303 303 } 304 304 305 305 /** 306 * Resets the $_SESSION cart array. This should be executed with the same consideration 306 * Resets the $_SESSION cart array. This should be executed with the same consideration 307 307 * as $auth->clear(), such as when logging out. 308 308 */ 309 309 public function clear() 310 310 { 311 $app =& App::getInstance(); 312 311 313 $_SESSION['_cart'][$this->_ns] = array( 312 314 'items' => array(), 313 315 ); 316 317 $app->logMsg(sprintf('Cleared %s cart', $this->_ns), LOG_DEBUG, __FILE__, __LINE__); 314 318 } 315 319 }
Note: See TracChangeset
for help on using the changeset viewer.