[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
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_shipping.php 1969 2005-09-13 06:57:21Z drbyte $ 21 // 22 23 class ot_shipping { 24 var $title, $output; 25 26 function ot_shipping() { 27 $this->code = 'ot_shipping'; 28 $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE; 29 $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION; 30 $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER; 31 32 $this->output = array(); 33 } 34 35 function process() { 36 global $order, $currencies; 37 38 if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') { 39 switch (MODULE_ORDER_TOTAL_SHIPPING_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_SHIPPING_FREE_SHIPPING_OVER) ) { 51 $order->info['shipping_method'] = $this->title; 52 $order->info['total'] -= $order->info['shipping_cost']; 53 $order->info['shipping_cost'] = 0; 54 } 55 } 56 $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_')); 57 if (zen_not_null($order->info['shipping_method'])) { 58 if ($GLOBALS[$module]->tax_class > 0) { 59 if (!defined($GLOBALS[$module]->tax_basis)) { 60 $shipping_tax_basis = STORE_SHIPPING_TAX_BASIS; 61 } else { 62 $shipping_tax_basis = $GLOBALS[$module]->tax_basis; 63 } 64 65 if ($shipping_tax_basis == 'Billing') { 66 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']); 67 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']); 68 } elseif ($shipping_tax_basis == 'Shipping') { 69 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); 70 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); 71 } else { 72 if (STORE_ZONE == $order->billing['zone_id']) { 73 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']); 74 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']); 75 } elseif (STORE_ZONE == $order->delivery['zone_id']) { 76 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); 77 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); 78 } else { 79 $shipping_tax = 0; 80 } 81 } 82 $order->info['tax'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 83 $order->info['tax_groups']["$shipping_tax_description"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 84 $order->info['total'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 85 86 if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax); 87 } 88 89 if ($_SESSION['shipping'] == 'free_free') $order->info['shipping_method'] = FREE_SHIPPING_TITLE; 90 91 $this->output[] = array('title' => $order->info['shipping_method'] . ':', 92 'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']), 93 'value' => $order->info['shipping_cost']); 94 } 95 } 96 97 function check() { 98 global $db; 99 if (!isset($this->_check)) { 100 $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'"); 101 $this->_check = $check_query->RecordCount(); 102 } 103 104 return $this->_check; 105 } 106 107 function keys() { 108 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'); 109 } 110 111 function install() { 112 global $db; 113 $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_SHIPPING_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())"); 114 $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_SHIPPING_SORT_ORDER', '200', 'Sort order of display.', '6', '2', now())"); 115 $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 Free Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', 'Do you want to allow free shipping?', '6', '3', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())"); 116 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Free Shipping For Orders Over', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', 'Provide free shipping for orders over the set amount.', '6', '4', 'currencies->format', now())"); 117 $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Provide Free Shipping For Orders Made', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', 'Provide free shipping for orders sent to the set destination.', '6', '5', 'zen_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())"); 118 } 119 120 function remove() { 121 global $db; 122 $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); 123 } 124 } 125 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |