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

   1  <?php
   2  //

   3  // +----------------------------------------------------------------------+

   4  // |zen-cart Open Source E-commerce                                       |

   5  // +----------------------------------------------------------------------+

   6  // | Copyright (c) 2004 The zen-cart developers                           |

   7  // |                                                                      |

   8  // | http://www.zen-cart.com/index.php                                    |

   9  // |                                                                      |

  10  // | Portions Copyright (c) 2003 osCommerce                               |

  11  // +----------------------------------------------------------------------+

  12  // | This source file is subject to version 2.0 of the GPL license,       |

  13  // | that is bundled with this package in the file LICENSE, and is        |

  14  // | available through the world-wide-web at the following url:           |

  15  // | http://www.zen-cart.com/license/2_0.txt.                             |

  16  // | If you did not receive a copy of the zen-cart license and are unable |

  17  // | to obtain it through the world-wide-web, please send a note to       |

  18  // | license@zen-cart.com so we can mail you a copy immediately.          |

  19  // +----------------------------------------------------------------------+

  20  // $Id: flat.php 1969 2005-09-13 06:57:21Z drbyte $

  21  //

  22  
  23    class flat {
  24      var $code, $title, $description, $icon, $enabled;
  25  
  26  // class constructor

  27      function flat() {
  28        global $order, $db;
  29  
  30        $this->code = 'flat';
  31        $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE;
  32        $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION;
  33        $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER;
  34        $this->icon = '';
  35        $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS;
  36        $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS;
  37  
  38        // disable only when entire cart is free shipping

  39        if (zen_get_shipping_enabled($this->code)) {
  40          $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false);
  41        }
  42  
  43        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) {
  44          $check_flag = false;
  45          $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
  46          while (!$check->EOF) {
  47            if ($check->fields['zone_id'] < 1) {
  48              $check_flag = true;
  49              break;
  50            } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
  51              $check_flag = true;
  52              break;
  53            }
  54            $check->MoveNext();
  55          }
  56  
  57          if ($check_flag == false) {
  58            $this->enabled = false;
  59          }
  60        }
  61      }
  62  
  63  // class methods

  64      function quote($method = '') {
  65        global $order;
  66  
  67        $this->quotes = array('id' => $this->code,
  68                              'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
  69                              'methods' => array(array('id' => $this->code,
  70                                                       'title' => MODULE_SHIPPING_FLAT_TEXT_WAY,
  71                                                       'cost' => MODULE_SHIPPING_FLAT_COST)));
  72        if ($this->tax_class > 0) {
  73          $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
  74        }
  75  
  76        if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title);
  77  
  78        return $this->quotes;
  79      }
  80  
  81      function check() {
  82        global $db;
  83        if (!isset($this->_check)) {
  84          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FLAT_STATUS'");
  85          $this->_check = $check_query->RecordCount();
  86        }
  87        return $this->_check;
  88      }
  89  
  90      function install() {
  91        global $db;
  92        $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 Flat Shipping', 'MODULE_SHIPPING_FLAT_STATUS', 'True', 'Do you want to offer flat rate shipping?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
  93        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_FLAT_COST', '5.00', 'The shipping cost for all orders using this shipping method.', '6', '0', now())");
  94        $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_FLAT_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())");
  95        $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_FLAT_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())");
  96        $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_FLAT_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())");
  97        $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_FLAT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  98      }
  99  
 100      function remove() {
 101        global $db;
 102        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 103      }
 104  
 105      function keys() {
 106        return array('MODULE_SHIPPING_FLAT_STATUS', 'MODULE_SHIPPING_FLAT_COST', 'MODULE_SHIPPING_FLAT_TAX_CLASS', 'MODULE_SHIPPING_FLAT_TAX_BASIS', 'MODULE_SHIPPING_FLAT_ZONE', 'MODULE_SHIPPING_FLAT_SORT_ORDER');
 107      }
 108    }
 109  ?>


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