[ 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/order_total/ -> ot_loworderfee.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: ot_loworderfee.php 4579 2006-09-21 20:20:49Z wilt $

  21  //

  22  
  23    class ot_loworderfee {
  24      var $title, $output;
  25  
  26      function ot_loworderfee() {
  27        $this->code = 'ot_loworderfee';
  28        $this->title = MODULE_ORDER_TOTAL_LOWORDERFEE_TITLE;
  29        $this->description = MODULE_ORDER_TOTAL_LOWORDERFEE_DESCRIPTION;
  30        $this->sort_order = MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER;
  31  
  32        $this->output = array();
  33      }
  34  
  35      function process() {
  36        global $order, $currencies;
  37  
  38        if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
  39          switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
  40            case 'national':
  41              if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
  42            case 'international':
  43              if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
  44            case 'both':
  45              $pass = true; break;
  46            default:
  47              $pass = false; break;
  48          }
  49  
  50  //        if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) {

  51          if ( ($pass == true) && ( $order->info['subtotal'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) {
  52            $charge_it = 'true';
  53            $cart_content_type = $_SESSION['cart']->get_content_type();
  54            $gv_content_only = $_SESSION['cart']->gv_only();
  55            if ($cart_content_type == 'physical' or $cart_content_type == 'mixed') {
  56              $charge_it = 'true';
  57            } else {
  58              // check to see if everything is virtual, if so - skip the low order fee.

  59              if ((($cart_content_type == 'virtual') and MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL == 'true')) {
  60                $charge_it = 'false';
  61                if ((($gv_content_only > 0) and MODULE_ORDER_TOTAL_LOWORDERFEE_GV == 'false')) {
  62                  $charge_it = 'true';
  63                }
  64              }
  65  
  66              if ((($gv_content_only > 0) and MODULE_ORDER_TOTAL_LOWORDERFEE_GV == 'true')) {
  67              // check to see if everything is gift voucher, if so - skip the low order fee.

  68                $charge_it = 'false';
  69                if ((($cart_content_type == 'virtual') and MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL == 'false')) {
  70                  $charge_it = 'true';
  71                }
  72              }
  73            }
  74  
  75            if ($charge_it == 'true') {
  76              $tax_address = zen_get_tax_locations();
  77              $tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
  78              $tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
  79  
  80  // calculate from flat fee or percentage

  81              if (substr(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, -1) == '%') {
  82                $low_order_fee = ($order->info['subtotal'] * (MODULE_ORDER_TOTAL_LOWORDERFEE_FEE/100));
  83              } else {
  84                $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
  85              }
  86  
  87  
  88              $order->info['tax'] += zen_calculate_tax($low_order_fee, $tax);
  89              $order->info['tax_groups']["$tax_description"] += zen_calculate_tax($low_order_fee, $tax);
  90              $order->info['total'] += $low_order_fee + zen_calculate_tax($low_order_fee, $tax);
  91              if (DISPLAY_PRICE_WITH_TAX == 'true') {
  92                $low_order_fee += zen_calculate_tax($low_order_fee, $tax);
  93              }
  94  
  95              $this->output[] = array('title' => $this->title . ':',
  96                                      'text' => $currencies->format($low_order_fee, true, $order->info['currency'], $order->info['currency_value']),
  97                                      'value' => $low_order_fee);
  98            }
  99          }
 100        }
 101      }
 102  
 103      function check() {
 104        global $db;
 105        if (!isset($this->_check)) {
 106          $check_query = "select configuration_value
 107                          from " . TABLE_CONFIGURATION . "
 108                          where configuration_key = 'MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS'";
 109  
 110          $check_query = $db->Execute($check_query);
 111          $this->_check = $check_query->RecordCount();
 112        }
 113  
 114        return $this->_check;
 115      }
 116  
 117      function keys() {
 118        return array('MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS', 'MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER', 'MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE', 'MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER', 'MODULE_ORDER_TOTAL_LOWORDERFEE_FEE', 'MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION', 'MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS', 'MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL', 'MODULE_ORDER_TOTAL_LOWORDERFEE_GV');
 119      }
 120  
 121      function install() {
 122        global $db;
 123        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
 124        $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_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER', '400', 'Sort order of display.', '6', '2', now())");
 125        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Allow Low Order Fee', 'MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE', 'false', 'Do you want to allow low order fees?', '6', '3', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
 126        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Order Fee For Orders Under', 'MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER', '50', 'Add the low order fee to orders under this amount.', '6', '4', 'currencies->format', now())");
 127        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Order Fee', 'MODULE_ORDER_TOTAL_LOWORDERFEE_FEE', '5', 'For Percentage Calculation - include a % Example: 10%<br />For a flat amount just enter the amount - Example: 5 for $5.00', '6', '5', '', now())");
 128        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Attach Low Order Fee On Orders Made', 'MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION', 'both', 'Attach low order fee for orders sent to the set destination.', '6', '6', 'zen_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
 129        $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_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS', '0', 'Use the following tax class on the low order fee.', '6', '7', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
 130        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('No Low Order Fee on Virtual Products', 'MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL', 'false', 'Do not charge Low Order Fee when cart is Virtual Products Only', '6', '8', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
 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 ('No Low Order Fee on Gift Vouchers', 'MODULE_ORDER_TOTAL_LOWORDERFEE_GV', 'false', 'Do not charge Low Order Fee when cart is Gift Vouchers Only', '6', '9', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
 132      }
 133  
 134      function remove() {
 135        global $db;
 136        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 137      }
 138    }
 139  ?>


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