[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/order_total/ -> ot_shipping.php (source)

   1  <?php
   2  /*

   3  $Id: ot_shipping.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    class ot_shipping {
  14      var $title, $output;
  15  
  16      function ot_shipping() {
  17        $this->code = 'ot_shipping';
  18        $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
  19        $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;
  20        $this->enabled = ((MODULE_ORDER_TOTAL_SHIPPING_STATUS == 'true') ? true : false);
  21        $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;
  22  
  23        $this->output = array();
  24      }
  25  
  26      function process() {
  27        global $order, $currencies;
  28  
  29        if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
  30          switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
  31            case 'national':
  32              if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
  33            case 'international':
  34              if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
  35            case 'both':
  36              $pass = true; break;
  37            default:
  38              $pass = false; break;
  39          }
  40  
  41          if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
  42            $order->info['shipping_method'] = FREE_SHIPPING_TITLE;
  43            $order->info['total'] -= $order->info['shipping_cost'];
  44            $order->info['shipping_cost'] = 0;
  45          }
  46        }
  47  
  48        $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
  49  
  50        if (tep_not_null($order->info['shipping_method'])) {
  51          if ($GLOBALS[$module]->tax_class > 0) {
  52            $shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  53            $shipping_tax_description = tep_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  54  
  55            $order->info['tax'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
  56            $order->info['tax_groups']["$shipping_tax_description"] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
  57            $order->info['total'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
  58  
  59            if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
  60          }
  61  
  62          $this->output[] = array('title' => $order->info['shipping_method'] . ':',
  63                                  'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
  64                                  'value' => $order->info['shipping_cost']);
  65        }
  66      }
  67  
  68      function check() {
  69        if (!isset($this->_check)) {
  70          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'");
  71          $this->_check = tep_db_num_rows($check_query);
  72        }
  73  
  74        return $this->_check;
  75      }
  76  
  77      function keys() {
  78        return array('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION');
  79      }
  80  
  81      function install() {
  82        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true', 'Do you want to display the order shipping cost?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  83        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())");
  84        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Free Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', 'Do you want to allow free shipping?', '6', '3', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  85        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Free Shipping For Orders Over', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', 'Provide free shipping for orders over the set amount.', '6', '4', 'currencies->format', now())");
  86        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Provide Free Shipping For Orders Made', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', 'Provide free shipping for orders sent to the set destination.', '6', '5', 'tep_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
  87      }
  88  
  89      function remove() {
  90        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  91      }
  92    }
  93  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7