Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 28 | /** |
| 29 | * Shopping Cart Class |
| 30 | * |
| 31 | * @package CodeIgniter |
| 32 | * @subpackage Libraries |
| 33 | * @category Shopping Cart |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 34 | * @author EllisLab Dev Team |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 35 | * @link http://codeigniter.com/user_guide/libraries/cart.html |
| 36 | */ |
| 37 | class CI_Cart { |
| 38 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 39 | /** |
| 40 | * These are the regular expression rules that we use to validate the product ID and product name |
| 41 | * alpha-numeric, dashes, underscores, or periods |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 42 | * |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 43 | * @var string |
| 44 | */ |
| 45 | public $product_id_rules = '\.a-z0-9_-'; |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 46 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 47 | /** |
| 48 | * These are the regular expression rules that we use to validate the product ID and product name |
| 49 | * alpha-numeric, dashes, underscores, colons or periods |
| 50 | * |
| 51 | * @var string |
| 52 | */ |
| 53 | public $product_name_rules = '\.\:\-_ a-z0-9'; |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 54 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 55 | /** |
| 56 | * only allow safe product names |
| 57 | * |
| 58 | * @var bool |
| 59 | */ |
| 60 | public $product_name_safe = TRUE; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 61 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 62 | // -------------------------------------------------------------------------- |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 63 | // Protected variables. Do not change! |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 64 | // -------------------------------------------------------------------------- |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 65 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 66 | /** |
| 67 | * Reference to CodeIgniter instance |
| 68 | * |
| 69 | * @var object |
| 70 | */ |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 71 | protected $CI; |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 72 | |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 73 | /** |
| 74 | * Contents of the cart |
| 75 | * |
| 76 | * @var array |
| 77 | */ |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 78 | protected $_cart_contents = array(); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Shopping Class Constructor |
| 82 | * |
| 83 | * The constructor loads the Session class, used to store the shopping cart contents. |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 84 | * |
| 85 | * @param array |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 86 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 87 | */ |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 88 | public function __construct($params = array()) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 89 | { |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 90 | // Set the super object to a local variable for use later |
| 91 | $this->CI =& get_instance(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 92 | |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 93 | // Are any config settings being passed manually? If so, set them |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 94 | $config = is_array($params) ? $params : array(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 95 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 96 | // Load the Sessions class |
| 97 | $this->CI->load->library('session', $config); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 98 | |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 99 | // Grab the shopping cart array from the session table |
| 100 | $this->_cart_contents = $this->CI->session->userdata('cart_contents'); |
| 101 | if ($this->_cart_contents === FALSE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 102 | { |
| 103 | // No cart exists so we'll set some base values |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 104 | $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 105 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 106 | |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 107 | log_message('debug', 'Cart Class Initialized'); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 111 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 112 | /** |
| 113 | * Insert items into the cart and save it to the session table |
| 114 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 115 | * @param array |
| 116 | * @return bool |
| 117 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 118 | public function insert($items = array()) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 119 | { |
| 120 | // Was any cart data passed? No? Bah... |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 121 | if ( ! is_array($items) OR count($items) === 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 122 | { |
| 123 | log_message('error', 'The insert method must be passed an array containing data.'); |
| 124 | return FALSE; |
| 125 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 126 | |
| 127 | // You can either insert a single product using a one-dimensional array, |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 128 | // or multiple products using a multi-dimensional one. The way we |
| 129 | // determine the array type is by looking for a required array key named "id" |
| 130 | // at the top level. If it's not found, we will assume it's a multi-dimensional array. |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 131 | |
| 132 | $save_cart = FALSE; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 133 | if (isset($items['id'])) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 134 | { |
Phil Sturgeon | 9091051 | 2011-07-20 10:07:40 -0600 | [diff] [blame] | 135 | if (($rowid = $this->_insert($items))) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 136 | { |
| 137 | $save_cart = TRUE; |
| 138 | } |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | foreach ($items as $val) |
| 143 | { |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 144 | if (is_array($val) && isset($val['id'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 145 | { |
Phil Sturgeon | 9091051 | 2011-07-20 10:07:40 -0600 | [diff] [blame] | 146 | if ($this->_insert($val)) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 147 | { |
| 148 | $save_cart = TRUE; |
| 149 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 150 | } |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
| 154 | // Save the cart data if the insert was successful |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 155 | if ($save_cart === TRUE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 156 | { |
| 157 | $this->_save_cart(); |
Phil Sturgeon | 9091051 | 2011-07-20 10:07:40 -0600 | [diff] [blame] | 158 | return isset($rowid) ? $rowid : TRUE; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | return FALSE; |
| 162 | } |
| 163 | |
| 164 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 165 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 166 | /** |
| 167 | * Insert |
| 168 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 169 | * @param array |
| 170 | * @return bool |
| 171 | */ |
Andrey Andreev | 74476e1 | 2012-03-26 15:03:40 +0300 | [diff] [blame] | 172 | protected function _insert($items = array()) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 173 | { |
| 174 | // Was any cart data passed? No? Bah... |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 175 | if ( ! is_array($items) OR count($items) === 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 176 | { |
| 177 | log_message('error', 'The insert method must be passed an array containing data.'); |
| 178 | return FALSE; |
| 179 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 180 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 181 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 182 | |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 183 | // Does the $items array contain an id, quantity, price, and name? These are required |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 184 | if ( ! isset($items['id'], $items['qty'], $items['price'], $items['name'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 185 | { |
| 186 | log_message('error', 'The cart array must contain a product ID, quantity, price, and name.'); |
| 187 | return FALSE; |
| 188 | } |
| 189 | |
| 190 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 191 | |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 192 | // Prep the quantity. It can only be a number. Duh... also trim any leading zeros |
Andrey Andreev | 17779d6 | 2011-12-22 13:21:08 +0200 | [diff] [blame] | 193 | $items['qty'] = (float) $items['qty']; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 194 | |
| 195 | // If the quantity is zero or blank there's nothing for us to do |
Andrey Andreev | 5036c9c | 2012-06-04 15:34:56 +0300 | [diff] [blame] | 196 | if ( ! is_numeric($items['qty']) OR $items['qty'] == 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 197 | { |
| 198 | return FALSE; |
| 199 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 200 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 201 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 202 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 203 | // Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods |
| 204 | // Not totally sure we should impose this rule, but it seems prudent to standardize IDs. |
| 205 | // Note: These can be user-specified by setting the $this->product_id_rules variable. |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 206 | if ( ! preg_match('/^['.$this->product_id_rules.']+$/i', $items['id'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 207 | { |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 208 | log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores'); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 209 | return FALSE; |
| 210 | } |
| 211 | |
| 212 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 213 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 214 | // Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods. |
| 215 | // Note: These can be user-specified by setting the $this->product_name_rules variable. |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 216 | if ($this->product_name_safe && ! preg_match('/^['.$this->product_name_rules.']+$/i', $items['name'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 217 | { |
Andrew Seymour | 3dd6663 | 2011-12-13 15:50:52 +0000 | [diff] [blame] | 218 | log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces'); |
| 219 | return FALSE; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | // -------------------------------------------------------------------- |
| 223 | |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 224 | // Prep the price. Remove leading zeros and anything that isn't a number or decimal point. |
Andrey Andreev | 17779d6 | 2011-12-22 13:21:08 +0200 | [diff] [blame] | 225 | $items['price'] = (float) $items['price']; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 226 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 227 | // Is the price a valid number? |
| 228 | if ( ! is_numeric($items['price'])) |
| 229 | { |
| 230 | log_message('error', 'An invalid price was submitted for product ID: '.$items['id']); |
| 231 | return FALSE; |
| 232 | } |
| 233 | |
| 234 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 235 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 236 | // We now need to create a unique identifier for the item being inserted into the cart. |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 237 | // Every time something is added to the cart it is stored in the master cart array. |
| 238 | // Each row in the cart array, however, must have a unique index that identifies not only |
| 239 | // a particular product, but makes it possible to store identical products with different options. |
| 240 | // For example, what if someone buys two identical t-shirts (same product ID), but in |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 241 | // different sizes? The product ID (and other attributes, like the name) will be identical for |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 242 | // both sizes because it's the same shirt. The only difference will be the size. |
| 243 | // Internally, we need to treat identical submissions, but with different options, as a unique product. |
| 244 | // Our solution is to convert the options array to a string and MD5 it along with the product ID. |
| 245 | // This becomes the unique "row ID" |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 246 | if (isset($items['options']) && count($items['options']) > 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 247 | { |
ThallisPHP | f074dff | 2012-05-03 16:01:46 -0300 | [diff] [blame] | 248 | $rowid = md5($items['id'].serialize($items['options'])); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 249 | } |
| 250 | else |
| 251 | { |
| 252 | // No options were submitted so we simply MD5 the product ID. |
| 253 | // Technically, we don't need to MD5 the ID in this case, but it makes |
| 254 | // sense to standardize the format of array indexes for both conditions |
| 255 | $rowid = md5($items['id']); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 256 | } |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 257 | |
| 258 | // -------------------------------------------------------------------- |
| 259 | |
| 260 | // Now that we have our unique "row ID", we'll add our cart items to the master array |
Andrew Seymour | 2e5bda3 | 2011-12-13 11:40:15 +0000 | [diff] [blame] | 261 | // grab quantity if it's already there and add it on |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 262 | $old_quantity = isset($this->_cart_contents[$rowid]['qty']) ? (int) $this->_cart_contents[$rowid]['qty'] : 0; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 263 | |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 264 | // Re-create the entry, just to make sure our index contains only the data from this submission |
| 265 | $items['rowid'] = $rowid; |
| 266 | $items['qty'] += $old_quantity; |
| 267 | $this->_cart_contents[$rowid] = $items; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 268 | |
Phil Sturgeon | 9091051 | 2011-07-20 10:07:40 -0600 | [diff] [blame] | 269 | return $rowid; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 273 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 274 | /** |
| 275 | * Update the cart |
| 276 | * |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 277 | * This function permits the quantity of a given item to be changed. |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 278 | * Typically it is called from the "view cart" page if a user makes |
| 279 | * changes to the quantity before checkout. That array must contain the |
| 280 | * product ID and quantity for each item. |
| 281 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 282 | * @param array |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 283 | * @return bool |
| 284 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 285 | public function update($items = array()) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 286 | { |
| 287 | // Was any cart data passed? |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 288 | if ( ! is_array($items) OR count($items) === 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 289 | { |
| 290 | return FALSE; |
| 291 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 292 | |
| 293 | // You can either update a single product using a one-dimensional array, |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 294 | // or multiple products using a multi-dimensional one. The way we |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 295 | // determine the array type is by looking for a required array key named "id". |
| 296 | // If it's not found we assume it's a multi-dimensional array |
| 297 | $save_cart = FALSE; |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 298 | if (isset($items['rowid'], $items['qty'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 299 | { |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 300 | if ($this->_update($items) === TRUE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 301 | { |
| 302 | $save_cart = TRUE; |
| 303 | } |
| 304 | } |
| 305 | else |
| 306 | { |
| 307 | foreach ($items as $val) |
| 308 | { |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 309 | if (is_array($val) && isset($val['rowid'], $val['qty'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 310 | { |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 311 | if ($this->_update($val) === TRUE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 312 | { |
| 313 | $save_cart = TRUE; |
| 314 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 315 | } |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | |
| 319 | // Save the cart data if the insert was successful |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 320 | if ($save_cart === TRUE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 321 | { |
| 322 | $this->_save_cart(); |
| 323 | return TRUE; |
| 324 | } |
| 325 | |
| 326 | return FALSE; |
| 327 | } |
| 328 | |
| 329 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 330 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 331 | /** |
| 332 | * Update the cart |
| 333 | * |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 334 | * This function permits the quantity of a given item to be changed. |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 335 | * Typically it is called from the "view cart" page if a user makes |
| 336 | * changes to the quantity before checkout. That array must contain the |
| 337 | * product ID and quantity for each item. |
| 338 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 339 | * @param array |
| 340 | * @return bool |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 341 | */ |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 342 | protected function _update($items = array()) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 343 | { |
| 344 | // Without these array indexes there is nothing we can do |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 345 | if ( ! isset($items['qty'], $items['rowid'], $this->_cart_contents[$items['rowid']])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 346 | { |
| 347 | return FALSE; |
| 348 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 349 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 350 | // Prep the quantity |
Andrey Andreev | 17779d6 | 2011-12-22 13:21:08 +0200 | [diff] [blame] | 351 | $items['qty'] = (float) $items['qty']; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 352 | |
| 353 | // Is the quantity a number? |
| 354 | if ( ! is_numeric($items['qty'])) |
| 355 | { |
| 356 | return FALSE; |
| 357 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 358 | |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 359 | // Is the quantity zero? If so we will remove the item from the cart. |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 360 | // If the quantity is greater than zero we are updating |
Andrey Andreev | 5036c9c | 2012-06-04 15:34:56 +0300 | [diff] [blame] | 361 | if ($items['qty'] == 0) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 362 | { |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 363 | unset($this->_cart_contents[$items['rowid']]); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 364 | } |
| 365 | else |
| 366 | { |
| 367 | $this->_cart_contents[$items['rowid']]['qty'] = $items['qty']; |
| 368 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 369 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 370 | return TRUE; |
| 371 | } |
| 372 | |
| 373 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 374 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 375 | /** |
| 376 | * Save the cart array to the session DB |
| 377 | * |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 378 | * @return bool |
| 379 | */ |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 380 | protected function _save_cart() |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 381 | { |
Rick Ellis | af4fb22 | 2009-02-24 22:44:22 +0000 | [diff] [blame] | 382 | // Lets add up the individual prices and set the cart sub-total |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 383 | $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 384 | foreach ($this->_cart_contents as $key => $val) |
| 385 | { |
| 386 | // We make sure the array contains the proper indexes |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 387 | if ( ! is_array($val) OR ! isset($val['price'], $val['qty'])) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 388 | { |
| 389 | continue; |
| 390 | } |
| 391 | |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 392 | $this->_cart_contents['cart_total'] += ($val['price'] * $val['qty']); |
| 393 | $this->_cart_contents['total_items'] += $val['qty']; |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 394 | $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 395 | } |
| 396 | |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 397 | // Is our cart empty? If so we delete it from the session |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 398 | if (count($this->_cart_contents) <= 2) |
| 399 | { |
| 400 | $this->CI->session->unset_userdata('cart_contents'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 401 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 402 | // Nothing more to do... coffee time! |
| 403 | return FALSE; |
| 404 | } |
| 405 | |
| 406 | // If we made it this far it means that our cart has data. |
| 407 | // Let's pass it to the Session class so it can be stored |
| 408 | $this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents)); |
| 409 | |
Andrey Andreev | 17779d6 | 2011-12-22 13:21:08 +0200 | [diff] [blame] | 410 | // Woot! |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 411 | return TRUE; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 415 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 416 | /** |
| 417 | * Cart Total |
| 418 | * |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 419 | * @return int |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 420 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 421 | public function total() |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 422 | { |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 423 | return $this->_cart_contents['cart_total']; |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 424 | } |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 425 | |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 426 | // -------------------------------------------------------------------- |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 427 | |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 428 | /** |
| 429 | * Remove Item |
| 430 | * |
| 431 | * Removes an item from the cart |
| 432 | * |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 433 | * @param int |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 434 | * @return bool |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 435 | */ |
| 436 | public function remove($rowid) |
| 437 | { |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 438 | // unset & save |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 439 | unset($this->_cart_contents[$rowid]); |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 440 | $this->_save_cart(); |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 441 | return TRUE; |
Andrew Seymour | f75ec11 | 2011-12-14 09:36:39 +0000 | [diff] [blame] | 442 | } |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 443 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 444 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 445 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 446 | /** |
| 447 | * Total Items |
| 448 | * |
| 449 | * Returns the total item count |
| 450 | * |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 451 | * @return int |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 452 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 453 | public function total_items() |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 454 | { |
| 455 | return $this->_cart_contents['total_items']; |
| 456 | } |
| 457 | |
| 458 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 459 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 460 | /** |
| 461 | * Cart Contents |
| 462 | * |
| 463 | * Returns the entire cart array |
| 464 | * |
Timothy Warren | 86611db | 2012-04-27 10:06:25 -0400 | [diff] [blame] | 465 | * @param bool |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 466 | * @return array |
| 467 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 468 | public function contents($newest_first = FALSE) |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 469 | { |
Andrew Seymour | de2e96a | 2011-12-13 16:44:59 +0000 | [diff] [blame] | 470 | // do we want the newest first? |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 471 | $cart = ($newest_first) ? array_reverse($this->_cart_contents) : $this->_cart_contents; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 472 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 473 | // Remove these so they don't create a problem when showing the cart table |
| 474 | unset($cart['total_items']); |
| 475 | unset($cart['cart_total']); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 476 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 477 | return $cart; |
| 478 | } |
| 479 | |
| 480 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 481 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 482 | /** |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 483 | * Get cart item |
| 484 | * |
| 485 | * Returns the details of a specific item in the cart |
| 486 | * |
| 487 | * @param string $row_id |
| 488 | * @return array |
| 489 | */ |
| 490 | public function get_item($row_id) |
| 491 | { |
| 492 | return (in_array($row_id, array('total_items', 'cart_total'), TRUE) OR ! isset($this->_cart_contents[$row_id])) |
| 493 | ? FALSE |
| 494 | : $this->_cart_contents[$row_id]; |
| 495 | } |
| 496 | |
| 497 | // -------------------------------------------------------------------- |
| 498 | |
| 499 | /** |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 500 | * Has options |
| 501 | * |
| 502 | * Returns TRUE if the rowid passed to this function correlates to an item |
| 503 | * that has options associated with it. |
| 504 | * |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 505 | * @param string $row_id = '' |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 506 | * @return bool |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 507 | */ |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 508 | public function has_options($row_id = '') |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 509 | { |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 510 | return (isset($this->_cart_contents[$row_id]['options']) && count($this->_cart_contents[$row_id]['options']) !== 0); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 514 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 515 | /** |
| 516 | * Product options |
| 517 | * |
| 518 | * Returns the an array of options, for a particular product row ID |
| 519 | * |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 520 | * @param string $row_id = '' |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 521 | * @return array |
| 522 | */ |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 523 | public function product_options($row_id = '') |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 524 | { |
Andrey Andreev | cdeee66 | 2012-10-25 17:29:52 +0300 | [diff] [blame^] | 525 | return isset($this->_cart_contents[$row_id]['options']) ? $this->_cart_contents[$row_id]['options'] : array(); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 526 | } |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 527 | |
| 528 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 529 | |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 530 | /** |
| 531 | * Format Number |
| 532 | * |
| 533 | * Returns the supplied number with commas and a decimal point. |
| 534 | * |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 535 | * @param float |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 536 | * @return string |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 537 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 538 | public function format_number($n = '') |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 539 | { |
Alex Bilbie | d261b1e | 2012-06-02 11:12:16 +0100 | [diff] [blame] | 540 | return ($n === '') ? '' : number_format( (float) $n, 2, '.', ','); |
Rick Ellis | df39d51 | 2009-02-24 22:29:37 +0000 | [diff] [blame] | 541 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 542 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 543 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 544 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 545 | /** |
| 546 | * Destroy the cart |
| 547 | * |
| 548 | * Empties the cart and kills the session |
| 549 | * |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 550 | * @return void |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 551 | */ |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 552 | public function destroy() |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 553 | { |
Andrey Andreev | bb24883 | 2011-12-21 16:42:51 +0200 | [diff] [blame] | 554 | $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0); |
Rick Ellis | 9c86ce5 | 2009-02-17 19:54:14 +0000 | [diff] [blame] | 555 | $this->CI->session->unset_userdata('cart_contents'); |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 558 | } |
Rick Ellis | 9878332 | 2009-02-17 02:29:44 +0000 | [diff] [blame] | 559 | |
| 560 | /* End of file Cart.php */ |
Andrey Andreev | 6f042cc | 2012-03-26 14:58:33 +0300 | [diff] [blame] | 561 | /* Location: ./system/libraries/Cart.php */ |