[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

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

   1  <?php
   2  /**

   3   * @package shippingMethod

   4   * @copyright Copyright 2003-2005 Zen Cart Development Team

   5   * @copyright Portions Copyright 2003 osCommerce

   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   7   * @version $Id: table.php 4184 2006-08-21 03:36:36Z ajeh $

   8   */
   9  /**

  10   * Enter description here...

  11   *

  12   */
  13  class table extends base {
  14    /**

  15     * Enter description here...

  16     *

  17     * @var unknown_type

  18     */
  19    var $code;
  20    /**

  21     * Enter description here...

  22     *

  23     * @var unknown_type

  24     */
  25    var $title;
  26    /**

  27     * Enter description here...

  28     *

  29     * @var unknown_type

  30     */
  31    var $description;
  32    /**

  33     * Enter description here...

  34     *

  35     * @var unknown_type

  36     */
  37    var $icon;
  38    /**

  39     * Enter description here...

  40     *

  41     * @var unknown_type

  42     */
  43    var $enabled;
  44    /**

  45     * Enter description here...

  46     *

  47     * @return table

  48     */
  49    function table() {
  50      global $order, $db;
  51  
  52      $this->code = 'table';
  53      $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE;
  54      $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION;
  55      $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER;
  56      $this->icon = '';
  57      $this->tax_class = MODULE_SHIPPING_TABLE_TAX_CLASS;
  58      $this->tax_basis = MODULE_SHIPPING_TABLE_TAX_BASIS;
  59      // disable only when entire cart is free shipping

  60      if (zen_get_shipping_enabled($this->code)) {
  61        $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);
  62      }
  63  
  64      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) {
  65        $check_flag = false;
  66        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
  67        while (!$check->EOF) {
  68          if ($check->fields['zone_id'] < 1) {
  69            $check_flag = true;
  70            break;
  71          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
  72            $check_flag = true;
  73            break;
  74          }
  75          $check->MoveNext();
  76        }
  77  
  78        if ($check_flag == false) {
  79          $this->enabled = false;
  80        }
  81      }
  82    }
  83    /**

  84     * Enter description here...

  85     *

  86     * @param unknown_type $method

  87     * @return unknown

  88     */
  89    function quote($method = '') {
  90      global $order, $shipping_weight, $shipping_num_boxes, $total_count;
  91  
  92      // shipping adjustment

  93      switch (MODULE_SHIPPING_TABLE_MODE) {
  94        case ('price'):
  95          $order_total = $_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices() ;
  96          break;
  97        case ('weight'):
  98          $order_total = $shipping_weight;
  99          break;
 100        case ('item'):
 101          $order_total = $total_count - $_SESSION['cart']->free_shipping_items();
 102          break;
 103      }
 104  
 105      $table_cost = split("[:,]" , MODULE_SHIPPING_TABLE_COST);
 106      $size = sizeof($table_cost);
 107      for ($i=0, $n=$size; $i<$n; $i+=2) {
 108        if (round($order_total,9) <= $table_cost[$i]) {
 109          $shipping = $table_cost[$i+1];
 110          break;
 111        }
 112      }
 113  
 114      if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
 115        $shipping = $shipping * $shipping_num_boxes;
 116        // show boxes if weight

 117        switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
 118          case (0):
 119          $show_box_weight = '';
 120          break;
 121          case (1):
 122          $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
 123          break;
 124          case (2):
 125          $show_box_weight = ' (' . number_format($shipping_weight * $shipping_num_boxes,2) . TEXT_SHIPPING_WEIGHT . ')';
 126          break;
 127          default:
 128          $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
 129          break;
 130        }
 131      }
 132  
 133      $this->quotes = array('id' => $this->code,
 134      'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE . $show_box_weight,
 135      'methods' => array(array('id' => $this->code,
 136      'title' => MODULE_SHIPPING_TABLE_TEXT_WAY,
 137      'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));
 138  
 139      if ($this->tax_class > 0) {
 140        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
 141      }
 142  
 143      if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
 144  
 145      return $this->quotes;
 146    }
 147    /**

 148     * Enter description here...

 149     *

 150     * @return unknown

 151     */
 152    function check() {
 153      global $db;
 154      if (!isset($this->_check)) {
 155        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_STATUS'");
 156        $this->_check = $check_query->RecordCount();
 157      }
 158      return $this->_check;
 159    }
 160    /**

 161     * Enter description here...

 162     *

 163     */
 164    function install() {
 165      global $db;
 166      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
 167      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Shipping Table', 'MODULE_SHIPPING_TABLE_COST', '25:8.50,50:5.50,10000:0.00', 'The shipping cost is based on the total cost or weight of items or count of the items. Example: 25:8.50,50:5.50,etc.. Up to 25 charge 8.50, from there to 50 charge 5.50, etc', '6', '0', 'zen_cfg_textarea(', now())");
 168      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Table Method', 'MODULE_SHIPPING_TABLE_MODE', 'weight', 'The shipping cost is based on the order total or the total weight of the items ordered or the total number of items orderd.', '6', '0', 'zen_cfg_select_option(array(\'weight\', \'price\', \'item\'), ', now())");
 169      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_TABLE_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
 170      $db->Execute("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_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
 171      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Tax Basis', 'MODULE_SHIPPING_TABLE_TAX_BASIS', 'Shipping', 'On what basis is Shipping Tax calculated. Options are<br />Shipping - Based on customers Shipping Address<br />Billing Based on customers Billing address<br />Store - Based on Store address if Billing/Shipping Zone equals Store zone', '6', '0', 'zen_cfg_select_option(array(\'Shipping\', \'Billing\', \'Store\'), ', now())");
 172      $db->Execute("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_TABLE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
 173      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_TABLE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
 174    }
 175    /**

 176     * Enter description here...

 177     *

 178     */
 179    function remove() {
 180      global $db;
 181      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 182    }
 183    /**

 184     * Enter description here...

 185     *

 186     * @return unknown

 187     */
 188    function keys() {
 189      return array('MODULE_SHIPPING_TABLE_STATUS', 'MODULE_SHIPPING_TABLE_COST', 'MODULE_SHIPPING_TABLE_MODE', 'MODULE_SHIPPING_TABLE_HANDLING', 'MODULE_SHIPPING_TABLE_TAX_CLASS', 'MODULE_SHIPPING_TABLE_TAX_BASIS', 'MODULE_SHIPPING_TABLE_ZONE', 'MODULE_SHIPPING_TABLE_SORT_ORDER');
 190    }
 191  }
 192  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics