[ 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/ -> freeshipper.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: freeshipper.php 1969 2005-09-13 06:57:21Z drbyte $

  21  //

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

  26      function freeshipper() {
  27        global $order, $db;
  28  
  29        $this->code = 'freeshipper';
  30        $this->title = MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE;
  31        $this->description = MODULE_SHIPPING_FREESHIPPER_TEXT_DESCRIPTION;
  32        $this->sort_order = MODULE_SHIPPING_FREESHIPPER_SORT_ORDER;
  33        $this->icon = '';
  34        $this->tax_class = MODULE_SHIPPING_FREESHIPPER_TAX_CLASS;
  35  
  36        // enable only when entire cart is free shipping

  37  //      if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {

  38        if (zen_get_shipping_enabled($this->code)) {
  39          $this->enabled = ((MODULE_SHIPPING_FREESHIPPER_STATUS == 'True') ? true : false);
  40        }
  41  
  42        if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREESHIPPER_ZONE > 0) ) {
  43          $check_flag = false;
  44          $check = $db->Execute("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");
  45          while (!$check->EOF) {
  46            if ($check->fields['zone_id'] < 1) {
  47              $check_flag = true;
  48              break;
  49            } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
  50              $check_flag = true;
  51              break;
  52            }
  53            $check->MoveNext();
  54          }
  55  
  56          if ($check_flag == false) {
  57            $this->enabled = false;
  58          }
  59        }
  60      }
  61  
  62  // class methods

  63      function quote($method = '') {
  64        global $order;
  65  
  66        $this->quotes = array('id' => $this->code,
  67                              'module' => MODULE_SHIPPING_FREESHIPPER_TEXT_TITLE,
  68                              'methods' => array(array('id' => $this->code,
  69                                                       'title' => MODULE_SHIPPING_FREESHIPPER_TEXT_WAY,
  70                                                       'cost' => MODULE_SHIPPING_FREESHIPPER_COST + MODULE_SHIPPING_FREESHIPPER_HANDLING)));
  71  
  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_FREESHIPPER_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 Free Shipping', 'MODULE_SHIPPING_FREESHIPPER_STATUS', 'True', 'Do you want to offer Free 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 ('Free Shipping Cost', 'MODULE_SHIPPING_FREESHIPPER_COST', '0.00', 'What is the Shipping cost?', '6', '6', now())");
  94        $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_FREESHIPPER_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
  95        $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_FREESHIPPER_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())");
  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_FREESHIPPER_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_FREESHIPPER_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_FREESHIPPER_STATUS', 'MODULE_SHIPPING_FREESHIPPER_COST', 'MODULE_SHIPPING_FREESHIPPER_HANDLING', 'MODULE_SHIPPING_FREESHIPPER_TAX_CLASS', 'MODULE_SHIPPING_FREESHIPPER_ZONE', 'MODULE_SHIPPING_FREESHIPPER_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