[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

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

   1  <?php
   2  /*

   3    WebMakers.com Added: Free Payments and Shipping

   4    Written by Linda McGrath [email protected]

   5    http://www.thewebmakerscorner.com

   6  

   7    osCMax Power E-Commerce

   8    http://oscdox.com

   9  

  10    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

  11  

  12    Released under the GNU General Public License

  13  */
  14  
  15    class freeshipper {
  16      var $code, $title, $description, $icon, $enabled;
  17  
  18  // BOF: WebMakers.com Added: Free Payments and Shipping

  19  // class constructor

  20      function freeshipper() {
  21        global $order, $cart;
  22        $this->code = 'freeshipper';
  23        $this->title = MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE;
  24        $this->description = MODULE_SHIPPING_FREESHIPPER_TEXT_DESCRIPTION;
  25        $this->sort_order = MODULE_SHIPPING_FREESHIPPER_SORT_ORDER;
  26        $this->icon = DIR_WS_ICONS . 'shipping_free_shipper.jpg';
  27        $this->tax_class = MODULE_SHIPPING_FREESHIPPER_TAX_CLASS;
  28        $this->enabled = ((MODULE_SHIPPING_FREESHIPPER_STATUS == 'True') ? true : false);
  29  
  30  // Only show if weight is 0

  31  //      if ( (!strstr($PHP_SELF,'modules.php')) || $cart->show_weight()==0) {

  32          $this->enabled = MODULE_SHIPPING_FREESHIPPER_STATUS;
  33          if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREESHIPPER_ZONE > 0) ) {
  34            $check_flag = false;
  35            $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FREESHIPPER_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
  36            while ($check = tep_db_fetch_array($check_query)) {
  37              if ($check['zone_id'] < 1) {
  38                $check_flag = true;
  39                break;
  40              } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
  41                $check_flag = true;
  42                break;
  43              }
  44            }
  45  
  46            if ($check_flag == false) {
  47              $this->enabled = false;
  48            }
  49          }
  50  //      }

  51  // EOF: WebMakers.com Added: Free Payments and Shipping

  52      }
  53  
  54  // class methods

  55      function quote($method = '') {
  56        global $order;
  57  
  58        $this->quotes = array('id' => $this->code,
  59                              'module' => MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE,
  60                              'methods' => array(array('id' => $this->code,
  61                                                       'title' => '<FONT COLOR=FF0000><B>' . MODULE_SHIPPING_FREESHIPPER_TEXT_WAY . '</B></FONT>',
  62                                                       'cost' => SHIPPING_HANDLING + MODULE_SHIPPING_FREESHIPPER_COST)));
  63  
  64        if ($this->tax_class > 0) {
  65          $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  66        }
  67        if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);
  68  
  69        return $this->quotes;
  70      }
  71  
  72      function check() {
  73        if (!isset($this->_check)) {
  74          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREESHIPPER_STATUS'");
  75          $this->_check = tep_db_num_rows($check_query);
  76        }
  77        return $this->_check;
  78      }
  79  
  80      function install() {
  81        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Enable Free Shipping', 'MODULE_SHIPPING_FREESHIPPER_STATUS', '1', 'Do you want to offer Free shipping?', '6', '5', now())");
  82        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Free Shipping Cost', 'MODULE_SHIPPING_FREESHIPPER_COST', '0.00', 'What is the Shipping cost? The Handling fee will also be added.', '6', '6', now())");
  83        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_FREESHIPPER_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())");
  84        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_FREESHIPPER_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())");
  85        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_FREESHIPPER_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  86      }
  87  
  88      function remove() {
  89        $keys = '';
  90        $keys_array = $this->keys();
  91        for ($i=0; $i<sizeof($keys_array); $i++) {
  92          $keys .= "'" . $keys_array[$i] . "',";
  93        }
  94        $keys = substr($keys, 0, -1);
  95  
  96        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
  97      }
  98  
  99      function keys() {
 100        return array('MODULE_SHIPPING_FREESHIPPER_STATUS', 'MODULE_SHIPPING_FREESHIPPER_COST', 'MODULE_SHIPPING_FREESHIPPER_TAX_CLASS', 'MODULE_SHIPPING_FREESHIPPER_ZONE', 'MODULE_SHIPPING_FREESHIPPER_SORT_ORDER');
 101      }
 102    }
 103  ?>


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