Projekt

Allgemein

Profil

GX-Bug #39712 » ot_shipping.php

/includes/modules/order_total/ - Till Tepelmann, 01.08.2014 14:23

 
1
<?php
2
/* --------------------------------------------------------------
3
   ot_shipping.php 2013-05-13 gm
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2013 Gambio GmbH
7
   Released under the GNU General Public License (Version 2)
8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9
   --------------------------------------------------------------
10

    
11

    
12
   based on: 
13
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
14
   (c) 2002-2003 osCommerce(ot_shipping.php,v 1.15 2003/02/07); www.oscommerce.com 
15
   (c) 2003	 nextcommerce (ot_shipping.php,v 1.13 2003/08/24); www.nextcommerce.org
16
   (c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: ot_shipping.php 1002 2005-07-10 16:11:37Z mz $)
17

    
18
   Released under the GNU General Public License 
19
   ---------------------------------------------------------------------------------------*/
20
   
21
  class ot_shipping_ORIGIN {
22
    var $title, $output;
23

    
24
    function ot_shipping_ORIGIN() {
25
    	global $xtPrice;
26
      $this->code = 'ot_shipping';
27
      $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
28
      $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;
29
      $this->enabled = ((MODULE_ORDER_TOTAL_SHIPPING_STATUS == 'true') ? true : false);
30
      $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;
31

    
32

    
33
      $this->output = array();
34
    }
35

    
36
    function process() {
37
      global $order, $xtPrice;
38

    
39
      if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
40
        switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
41
          case 'national':
42
            if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
43
          case 'international':
44
            if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
45
          case 'both':
46
            $pass = true; break;
47
          default:
48
            $pass = false; break;
49
        }
50

    
51
		$t_shipping_free_over = (double)MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER;
52
		if($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 
53
			&& (int)MODULE_ORDER_TOTAL_SHIPPING_TAX_CLASS > 0)
54
		{
55
			$t_shipping_free_over = $t_shipping_free_over / (1 + $xtPrice->TAX[MODULE_ORDER_TOTAL_SHIPPING_TAX_CLASS] / 100);
56
		}
57

    
58
        if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) >= $xtPrice->xtcFormat($t_shipping_free_over,false,0,true)) ) {
59
          $order->info['shipping_method'] = $this->title;
60
          $order->info['total'] -= $order->info['shipping_cost'];
61
          $order->info['shipping_cost'] = 0;
62
        }
63
      }
64

    
65
      $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
66

    
67
      // BOF GM_MOD
68
      if(!isset($GLOBALS[$module]) && file_exists(DIR_FS_CATALOG . 'includes/modules/shipping/' . basename($module) . '.php'))
69
      {
70
      	include_once(DIR_FS_CATALOG . 'includes/modules/shipping/' . basename($module) . '.php');
71
      	$GLOBALS[$module] = new $module;
72
      } 
73
      // EOF GM_MOD
74

    
75
      if (xtc_not_null($order->info['shipping_method'])) {
76
        if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) {
77
        // price with tax
78

    
79
          $shipping_tax = xtc_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country_id'], $order->delivery['zone_id']);
80
          $shipping_tax_description = xtc_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country_id'], $order->delivery['zone_id']);
81
          $tax = $xtPrice->xtcFormat(xtc_add_tax($order->info['shipping_cost'], $shipping_tax),false,0,false)-$order->info['shipping_cost'];
82

    
83
          $tax = $xtPrice->xtcCalculateCurr($tax);
84

    
85
          $order->info['shipping_cost'] = xtc_add_tax($order->info['shipping_cost'], $shipping_tax);
86
          $order->info['tax'] += $tax;
87
          $order->info['tax_groups'][TAX_ADD_TAX . "$shipping_tax_description"] += $tax;
88

    
89
          $tax = $xtPrice->xtcFormat($tax,false,0,false);
90

    
91
          $order->info['total'] += $tax;
92

    
93
        } else {
94

    
95
        if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
96

    
97
          $shipping_tax = xtc_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
98
          $shipping_tax_description = xtc_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
99
          $tax = $xtPrice->xtcFormat(xtc_add_tax($order->info['shipping_cost'], $shipping_tax),false,0,false)-$order->info['shipping_cost'];
100

    
101
		  $tax = $xtPrice->xtcCalculateCurr($tax);
102

    
103
          $order->info['tax'] = $order->info['tax'] += $tax;
104
          $order->info['tax_groups'][TAX_NO_TAX . "$shipping_tax_description"] = $order->info['tax_groups'][TAX_NO_TAX . "$shipping_tax_description"] += $tax;
105
        }
106
        }
107
        $this->output[] = array('title' => $order->info['shipping_method'] . ':',
108
                                'text' => $xtPrice->xtcFormat($order->info['shipping_cost'], true,0,true),
109
                                'value' => $xtPrice->xtcFormat($order->info['shipping_cost'], false,0,true));
110
      }
111
    }
112

    
113
    function check() {
114
      if (!isset($this->_check)) {
115
        $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'");
116
        $this->_check = xtc_db_num_rows($check_query);
117
      }
118

    
119
      return $this->_check;
120
    }
121

    
122
    function keys() {
123
      return array('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'MODULE_ORDER_TOTAL_SHIPPING_TAX_CLASS');
124
    }
125

    
126
    function install() {
127
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true','6', '1','xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
128
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', '30','6', '2', now())");
129
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false','6', '3', 'xtc_cfg_select_option(array(\'true\', \'false\'), ', now())");
130
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', '6', '4', 'currencies->format', now())");
131
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national','6', '5', 'xtc_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
132
      xtc_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) values ('MODULE_ORDER_TOTAL_SHIPPING_TAX_CLASS', '0','6', '7', 'xtc_get_tax_class_title', 'xtc_cfg_pull_down_tax_classes(', now())");      
133
    }
134

    
135
    function remove() {
136
      xtc_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
137
    }
138
  }
139
  
140
MainFactory::load_origin_class('ot_shipping');
(2-2/2)