1, 'shipping_weight' => 0, 'quotes' => array()); } $this->_shipping_boxes =& $_SESSION['osC_Shipping_data']['shipping_boxes']; $this->_shipping_weight =& $_SESSION['osC_Shipping_data']['shipping_weight']; $this->_quotes =& $_SESSION['osC_Shipping_data']['quotes']; if (defined('MODULE_SHIPPING_INSTALLED') && (osc_empty(MODULE_SHIPPING_INSTALLED) === false)) { $this->_modules = explode(';', MODULE_SHIPPING_INSTALLED); $include_modules = array(); if ( (empty($module) === false) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($_SERVER['PHP_SELF'], (strrpos($_SERVER['PHP_SELF'], '.')+1)), $this->_modules)) ) { $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($_SERVER['PHP_SELF'], (strrpos($_SERVER['PHP_SELF'], '.')+1))); } else { foreach ($this->_modules as $value) { $class = substr($value, 0, strrpos($value, '.')); $include_modules[] = array('class' => $class, 'file' => $value); } } $osC_Language->load('modules-shipping'); foreach ($include_modules as $module) { include('includes/modules/shipping/' . $module['file']); $GLOBALS[$module['class']] = new $module['class']; } } } function calculateQuotes($method = '', $module = '') { global $osC_ShoppingCart; $this->_quotes = array(); if (is_array($this->_modules)) { $this->_shipping_weight = $osC_ShoppingCart->getWeight(); if (SHIPPING_BOX_WEIGHT >= ($this->_shipping_weight * SHIPPING_BOX_PADDING/100)) { $this->_shipping_weight = $this->_shipping_weight + SHIPPING_BOX_WEIGHT; } else { $this->_shipping_weight = $this->_shipping_weight + ($this->_shipping_weight * SHIPPING_BOX_PADDING/100); } if ($this->_shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes $this->_shipping_boxes = ceil($this->_shipping_weight / SHIPPING_MAX_WEIGHT); $this->_shipping_weight = $this->_shipping_weight / $this->_shipping_boxes; } $include_quotes = array(); foreach ($this->_modules as $value) { $class = substr($value, 0, strrpos($value, '.')); if (tep_not_null($module)) { if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) { $include_quotes[] = $class; } } elseif ($GLOBALS[$class]->enabled) { $include_quotes[] = $class; } } foreach ($include_quotes as $module) { $quotes = $GLOBALS[$module]->quote($method); if (is_array($quotes)) { $this->_quotes[] = $quotes; } } } } function hasQuotes() { return !empty($this->_quotes); } function getQuotes($method = '', $module = '') { if ( (empty($method) === false) && (empty($module) === false) ) { foreach ($this->_quotes as $quote) { if ($quote['id'] == $module) { foreach ($quote['methods'] as $quote_method) { if ($quote_method['id'] == $method) { return array('id' => $quote['id'], 'module' => $quote['module'], 'methods' => $quote_method, 'tax' => $quote['tax']); } } } } } return $this->_quotes; } function getCheapestQuote() { if (is_array($this->_modules)) { $rates = array(); foreach ($this->_modules as $value) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled) { $quotes = $GLOBALS[$class]->quotes; for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) { if (isset($quotes['methods'][$i]['cost']) && tep_not_null($quotes['methods'][$i]['cost'])) { $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'], 'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')', 'cost' => $quotes['methods'][$i]['cost']); } } } } $cheapest = false; for ($i=0, $n=sizeof($rates); $i<$n; $i++) { if (is_array($cheapest)) { if ($rates[$i]['cost'] < $cheapest['cost']) { $cheapest = $rates[$i]; } } else { $cheapest = $rates[$i]; } } return $cheapest; } } } ?>