[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/modules/shipping/ -> item.php (source)

   1  <?php
   2  /*

   3  $Id: item.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 item {
  14      var $code, $title, $description, $icon, $enabled;
  15  
  16  // class constructor

  17      function item() {
  18        global $order;
  19  
  20        $this->code = 'item';
  21        $this->title = MODULE_SHIPPING_ITEM_TEXT_TITLE;
  22        $this->description = MODULE_SHIPPING_ITEM_TEXT_DESCRIPTION;
  23        $this->sort_order = MODULE_SHIPPING_ITEM_SORT_ORDER;
  24        $this->icon = '';
  25        $this->tax_class = MODULE_SHIPPING_ITEM_TAX_CLASS;
  26        $this->enabled = ((MODULE_SHIPPING_ITEM_STATUS == 'True') ? true : false);
  27  
  28        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_ITEM_ZONE > 0) ) {
  29          $check_flag = false;
  30          $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_ITEM_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
  31          while ($check = tep_db_fetch_array($check_query)) {
  32            if ($check['zone_id'] < 1) {
  33              $check_flag = true;
  34              break;
  35            } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
  36              $check_flag = true;
  37              break;
  38            }
  39          }
  40  
  41          if ($check_flag == false) {
  42            $this->enabled = false;
  43          }
  44        }
  45      }
  46  
  47  // class methods

  48      function quote($method = '') {
  49        global $order, $total_count;
  50  
  51        $this->quotes = array('id' => $this->code,
  52                              'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE,
  53                              'methods' => array(array('id' => $this->code,
  54                                                       'title' => MODULE_SHIPPING_ITEM_TEXT_WAY,
  55                                                       'cost' => (MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING)));
  56  
  57        if ($this->tax_class > 0) {
  58          $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  59        }
  60  
  61        if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
  62  
  63        return $this->quotes;
  64      }
  65  
  66      function check() {
  67        if (!isset($this->_check)) {
  68          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_ITEM_STATUS'");
  69          $this->_check = tep_db_num_rows($check_query);
  70        }
  71        return $this->_check;
  72      }
  73  
  74      function install() {
  75        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 ('Enable Item Shipping', 'MODULE_SHIPPING_ITEM_STATUS', 'True', 'Do you want to offer per item rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  76        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_ITEM_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '6', '0', now())");
  77        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_ITEM_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
  78        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_ITEM_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
  79        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_ITEM_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
  80        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_SHIPPING_ITEM_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  81      }
  82  
  83      function remove() {
  84        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  85      }
  86  
  87      function keys() {
  88        return array('MODULE_SHIPPING_ITEM_STATUS', 'MODULE_SHIPPING_ITEM_COST', 'MODULE_SHIPPING_ITEM_HANDLING', 'MODULE_SHIPPING_ITEM_TAX_CLASS', 'MODULE_SHIPPING_ITEM_ZONE', 'MODULE_SHIPPING_ITEM_SORT_ORDER');
  89      }
  90    }
  91  ?>


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