/modules/osC/includes/modules/order_total/ot_loworderfee.php

https://github.com/severnaya99/Sg-2010 · PHP · 84 lines · 61 code · 12 blank · 11 comment · 12 complexity · 3b3c4d33b5947fada63039babd930b3f MD5 · raw file

  1. <?php
  2. /**
  3. * $Id: ot_loworderfee.php 58 2005-12-15 16:21:17Z Michael $
  4. * osCommerce, Open Source E-Commerce Solutions
  5. * http://www.oscommerce.com
  6. * Copyright (c) 2003 osCommerce
  7. * Released under the GNU General Public License
  8. * adapted 2005 for xoops by FlinkUX <http://www.flinkux.de>
  9. * @package xosC
  10. * @author Michael Hammelmann <michael.hammelmann@flinkux.de>
  11. * @version 1
  12. **/
  13. class ot_loworderfee {
  14. var $title, $output;
  15. function ot_loworderfee() {
  16. $this->code = 'ot_loworderfee';
  17. $this->title = MODULE_ORDER_TOTAL_LOWORDERFEE_TITLE;
  18. $this->description = MODULE_ORDER_TOTAL_LOWORDERFEE_DESCRIPTION;
  19. $this->enabled = ((MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS == 'true') ? true : false);
  20. $this->sort_order = MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER;
  21. $this->credit_class = false;
  22. $this->output = array();
  23. }
  24. function process() {
  25. global $order, $currencies;
  26. if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
  27. switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
  28. case 'national':
  29. if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;
  30. case 'international':
  31. if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;
  32. case 'both':
  33. $pass = true; break;
  34. default:
  35. $pass = false; break;
  36. }
  37. if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) {
  38. $tax = tep_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
  39. $tax_description = tep_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']);
  40. $order->info['tax'] += tep_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
  41. $order->info['tax_groups']["$tax_description"] += tep_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
  42. $order->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + tep_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
  43. $this->output[] = array('title' => $this->title . ':',
  44. 'text' => $currencies->format(tep_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), true, $order->info['currency'], $order->info['currency_value']),
  45. 'value' => tep_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax));
  46. }
  47. }
  48. }
  49. function check() {
  50. if (!isset($this->_check)) {
  51. $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS'");
  52. $this->_check = tep_db_num_rows($check_query);
  53. }
  54. return $this->_check;
  55. }
  56. function keys() {
  57. 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');
  58. }
  59. function install() {
  60. tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Low Order Fee', 'MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS', 'true', 'Do you want to display the low order fee?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  61. tep_db_query("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', '4', 'Sort order of display.', '6', '2', now())");
  62. tep_db_query("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', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  63. tep_db_query("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())");
  64. tep_db_query("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', 'Low order fee.', '6', '5', 'currencies->format', now())");
  65. tep_db_query("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', 'tep_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
  66. tep_db_query("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', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
  67. }
  68. function remove() {
  69. tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
  70. }
  71. }
  72. ?>