[ 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/ -> perweightunit.php (source)

   1  <?php
   2  /**

   3   * @package shippingMethod

   4   * @copyright Copyright 2003-2006 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: perweightunit.php 3308 2006-03-29 08:21:33Z ajeh $

   8   */
   9  /**

  10   * "Per Weight Unit" shipping module, allowing you to offer per-unit-rate shipping options

  11   *

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

  15     * $code determines the internal 'code' name used to designate "this" payment module

  16     *

  17     * @var string

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

  21     * $title is the displayed name for this payment method

  22     *

  23     * @var string

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

  27     * $description is a soft name for this payment method

  28     *

  29     * @var string

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

  33     * module's icon

  34     *

  35     * @var string

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

  39     * $enabled determines whether this module shows or not... during checkout.

  40     *

  41     * @var boolean

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

  45       * Constructor

  46     *

  47     * @return perweightunit

  48     */
  49    function perweightunit() {
  50      global $order, $db;
  51  
  52      $this->code = 'perweightunit';
  53      $this->title = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE;
  54      $this->description = MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_DESCRIPTION;
  55      $this->sort_order = MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER;
  56      $this->icon = '';
  57      $this->tax_class = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS;
  58      $this->tax_basis = MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS;
  59  
  60      // disable only when entire cart is free shipping

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

  88     * Obtain quote from shipping system/calculations

  89     *

  90     * @param string $method

  91     * @return array

  92     */
  93    function quote($method = '') {
  94      global $order, $shipping_weight;
  95  
  96      $total_weight_units = $shipping_weight;
  97      $this->quotes = array('id' => $this->code,
  98                            'module' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_TITLE,
  99                            'methods' => array(array('id' => $this->code,
 100                                                     'title' => MODULE_SHIPPING_PERWEIGHTUNIT_TEXT_WAY,
 101                                                     'cost' => (MODULE_SHIPPING_PERWEIGHTUNIT_COST * $total_weight_units)
 102                                                                + MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING)));
 103  
 104      if ($this->tax_class > 0) {
 105        $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
 106      }
 107  
 108      if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
 109  
 110      return $this->quotes;
 111    }
 112    /**

 113     * Check to see whether module is installed

 114     *

 115     * @return boolean

 116     */
 117    function check() {
 118      global $db;
 119      if (!isset($this->_check)) {
 120        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_PERWEIGHTUNIT_STATUS'");
 121        $this->_check = $check_query->RecordCount();
 122      }
 123      return $this->_check;
 124    }
 125    /**

 126     * Install the shipping module and its configuration settings

 127     *

 128     */
 129    function install() {
 130      global $db;
 131      $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 Per Weight Unit Shipping', 'MODULE_SHIPPING_PERWEIGHTUNIT_STATUS', 'True', 'Do you want to offer per unit rate shipping?<br /><br />Product Quantity * Units (products_weight) * Cost per Unit', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
 132      $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost per Unit', 'MODULE_SHIPPING_PERWEIGHTUNIT_COST', '1', 'NOTE: When using this Shipping Module be sure to check the Tare settings in the Shipping/Packaging and set the Largest Weight high enough to handle the price, such as 5000.00 and the adjust the settings on Small and Large packages which will add to the price as well.<br /><br />The shipping cost will be used to determin shipping charges based on: Product Quantity * Units (products_weight) * Cost per Unit - in an order that uses this shipping method.', '6', '0', now())");
 133      $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_PERWEIGHTUNIT_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
 134      $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_PERWEIGHTUNIT_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())");
 135      $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_PERWEIGHTUNIT_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())");
 136      $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_PERWEIGHTUNIT_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())");
 137      $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_PERWEIGHTUNIT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
 138    }
 139    /**

 140     * Remove the module and all its settings

 141     *

 142     */
 143    function remove() {
 144      global $db;
 145      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE  'MODULE_SHIPPING_PERWEIGHTUNIT_%'");
 146    }
 147    /**

 148     * Internal list of configuration keys used for configuration of the module

 149     *

 150     * @return array

 151     */
 152    function keys() {
 153      return array('MODULE_SHIPPING_PERWEIGHTUNIT_STATUS', 'MODULE_SHIPPING_PERWEIGHTUNIT_COST', 'MODULE_SHIPPING_PERWEIGHTUNIT_HANDLING', 'MODULE_SHIPPING_PERWEIGHTUNIT_TAX_CLASS', 'MODULE_SHIPPING_PERWEIGHTUNIT_TAX_BASIS', 'MODULE_SHIPPING_PERWEIGHTUNIT_ZONE', 'MODULE_SHIPPING_PERWEIGHTUNIT_SORT_ORDER');
 154    }
 155  }
 156  ?>


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