  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: shipping.php 865 2006-08-30 01:22:41Z hpdl $ |
| |
| 3 | + | $Id: shipping.php 1421 2007-03-08 00:24:29Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
20 | 20 | | function osC_Shipping($module = '') { |
| |
21 | 21 | | global $osC_Database, $osC_Language; |
| |
22 | 22 | | |
  |
23 | | - | if (isset($_SESSION['osC_Shipping_data']) === false) { |
| |
24 | | - | $_SESSION['osC_Shipping_data'] = array('quotes' => array(), |
| |
25 | | - | 'cartID' => null); |
| |
26 | | - | } |
| |
| 23 | + | $this->_quotes =& $_SESSION['osC_ShoppingCart_data']['shipping_quotes']; |
|
27 | 24 | | |
  |
28 | | - | $this->_quotes =& $_SESSION['osC_Shipping_data']['quotes']; |
| |
29 | | - | $this->_cartID =& $_SESSION['osC_Shipping_data']['cartID']; |
| |
30 | | - | |
|
31 | 25 | | $Qmodules = $osC_Database->query('select code from :table_templates_boxes where modules_group = "shipping"'); |
| |
32 | 26 | | $Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
33 | 27 | | $Qmodules->setCache('modules-shipping'); |
| |
|
|
 |
… |
|
61 | 55 | | usort($this->_modules, array('osC_Shipping', '_usortModules')); |
| |
62 | 56 | | } |
| |
63 | 57 | | |
  |
64 | | - | $this->_calculate(); |
| |
| 58 | + | if ( empty($this->_quotes) ) { |
| |
| 59 | + | $this->_calculate(); |
| |
| 60 | + | } |
|
65 | 61 | | } |
| |
66 | 62 | | |
| |
67 | 63 | | // class methods |
| |
|
|
 |
… |
|
171 | 167 | | } |
| |
172 | 168 | | |
| |
173 | 169 | | function _calculate() { |
  |
174 | | - | global $osC_ShoppingCart; |
| |
| 170 | + | $this->_quotes = array(); |
|
175 | 171 | | |
  |
176 | | - | if ($this->_cartID != $osC_ShoppingCart->getCartID()) { |
| |
177 | | - | $this->_cartID = $osC_ShoppingCart->getCartID(); |
| |
| 172 | + | if (is_array($this->_modules)) { |
| |
| 173 | + | $include_quotes = array(); |
|
178 | 174 | | |
  |
179 | | - | $this->_quotes = array(); |
| |
180 | | - | |
| |
181 | | - | if (is_array($this->_modules)) { |
| |
182 | | - | $include_quotes = array(); |
| |
183 | | - | |
| |
184 | | - | if (defined('MODULE_SHIPPING_FREE_STATUS') && isset($GLOBALS['osC_Shipping_free']) && $GLOBALS['osC_Shipping_free']->isEnabled()) { |
| |
185 | | - | $include_quotes[] = 'osC_Shipping_free'; |
| |
186 | | - | } else { |
| |
187 | | - | foreach ($this->_modules as $module) { |
| |
188 | | - | if ($GLOBALS['osC_Shipping_' . $module]->isEnabled()) { |
| |
189 | | - | $include_quotes[] = 'osC_Shipping_' . $module; |
| |
190 | | - | } |
| |
| 175 | + | if (defined('MODULE_SHIPPING_FREE_STATUS') && isset($GLOBALS['osC_Shipping_free']) && $GLOBALS['osC_Shipping_free']->isEnabled()) { |
| |
| 176 | + | $include_quotes[] = 'osC_Shipping_free'; |
| |
| 177 | + | } else { |
| |
| 178 | + | foreach ($this->_modules as $module) { |
| |
| 179 | + | if ($GLOBALS['osC_Shipping_' . $module]->isEnabled()) { |
| |
| 180 | + | $include_quotes[] = 'osC_Shipping_' . $module; |
|
191 | 181 | | } |
| |
192 | 182 | | } |
  |
| 183 | + | } |
|
193 | 184 | | |
  |
194 | | - | foreach ($include_quotes as $module) { |
| |
195 | | - | $quotes = $GLOBALS[$module]->quote(); |
| |
| 185 | + | foreach ($include_quotes as $module) { |
| |
| 186 | + | $quotes = $GLOBALS[$module]->quote(); |
|
196 | 187 | | |
  |
197 | | - | if (is_array($quotes)) { |
| |
198 | | - | $this->_quotes[] = $quotes; |
| |
199 | | - | } |
| |
| 188 | + | if (is_array($quotes)) { |
| |
| 189 | + | $this->_quotes[] = $quotes; |
  |
200 | 190 | | } |
| |
201 | 191 | | } |
| |
202 | 192 | | } |