PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,160 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_cmembers.php,v 1.1 2007/06/07 17:30:50 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_cmembers.php,v 1.1 2003/01/08 10:53:04 elarifr
ot_lev_members.php,v 1.0 2002/04/08 01:13:43 hpdl
----------------------------------------------------------------------
Customers_status v3.x / Catalog part
Copyright elari@free.fr
Contribution based on:
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 - 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_cmembers {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_cmembers';
$this->title = $aLang['module_cmembers_title'];
$this->description = $aLang['module_cmembers_description'];
$this->enabled = (defined('MODULE_CMEMBERS_STATUS') && (MODULE_CMEMBERS_STATUS == 'true') ? TRUE : FALSE);
$this->sort_order = (defined('MODULE_CMEMBERS_SORT_ORDER') ? MODULE_CMEMBERS_SORT_ORDER : null);
$this->include_shipping = (defined('MODULE_CMEMBERS_INC_SHIPPING') ? MODULE_CMEMBERS_INC_SHIPPING : null);
$this->include_tax = (defined('MODULE_CMEMBERS_INC_TAX') ? MODULE_CMEMBERS_INC_TAX : null);
$this->calculate_tax = (defined('MODULE_CMEMBERS_CALC_TAX') ? MODULE_CMEMBERS_CALC_TAX : null);
$this->percentage = (defined('MODULE_CMEMBERS_OT_DISCOUNT') ? MODULE_CMEMBERS_OT_DISCOUNT : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
$od_amount = $this->calculate_credit($this->get_order_total());
if ($od_amount>0) {
$this->deduction = $od_amount;
$this->output[] = array('title' => '<span class="otDiscount">- ' . $this->title . ' ('. number_format($this->percentage, 2) .'%):</span>',
'text' => '<strong><span class="otDiscount">' . $oCurrencies->format($od_amount) . '</span></strong>',
'value' => $od_amount);
$oOrder->info['total'] = $oOrder->info['total'] - $od_amount;
}
}
function calculate_credit($amount) {
global $oOrder, $customer_id, $customer_status_value;
$od_amount=0;
$od_pc = $this->percentage;
$cart_count = $_SESSION['cart']->count_contents();
if (MODULE_CMEMBERS_CART_COUNT < $cart_count) {
if ($this->calculate_tax == 'true') { // Calculate main tax reduction
$tod_amount = round($oOrder->info['tax']*10)/10*$od_pc/100;
$oOrder->info['tax'] = $oOrder->info['tax'] - $tod_amount; // Calculate tax group deductions
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$god_amount = round($value*10)/10*$od_pc/100;
$oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount;
}
}
$od_amount = round($amount*10)/10*$od_pc/100;
$od_amount = $od_amount + $tod_amount;
}
return $od_amount;
}
function get_order_total() {
global $oOrder;
$order_total = $oOrder->info['total'];
// Check if gift voucher is in cart and adjust total
$products = $_SESSION['cart']->get_products();
for ($i=0; $i<count($products); $i++) {
$t_prid = oos_get_product_id($products[$i]['id']);
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$productstable = $oostable['products'];
$query = "SELECT products_price, products_tax_class_id, products_model
FROM $productstable
WHERE products_id = '" . intval($t_prid) . "'";
$gv_result = $dbconn->GetRow($query);
if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) {
$qty = $_SESSION['cart']->get_quantity($t_prid);
$products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']);
if ($this->include_tax =='false') {
$gv_amount = $gv_result['products_price'] * $qty;
} else {
$gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
}
$order_total = $order_total - $gv_amount;
}
}
if ($this->include_tax == 'false') $order_total = $order_total-$oOrder->info['tax'];
if ($this->include_shipping == 'false') $order_total = $order_total-$oOrder->info['shipping_cost'];
return $order_total;
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_CMEMBERS_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_CMEMBERS_STATUS', 'MODULE_CMEMBERS_SORT_ORDER', 'MODULE_CMEMBERS_CART_COUNT', 'MODULE_CMEMBERS_OT_DISCOUNT', 'MODULE_CMEMBERS_INC_SHIPPING', 'MODULE_CMEMBERS_INC_TAX', 'MODULE_CMEMBERS_CALC_TAX');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_CMEMBERS_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_SORT_ORDER', '12', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_CART_COUNT', '5', '6', '3', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_CMEMBERS_OT_DISCOUNT', '10', '6', '4', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_INC_SHIPPING', 'true', '6', '5', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_INC_TAX', 'true', '6', '6','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_CMEMBERS_CALC_TAX', 'false', '6', '7','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,165 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_cod_fee.php,v 1.1 2007/06/07 17:30:50 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_cod_fee.php,v 1.02 2003/02/24 06:05:00 harley_vb
----------------------------------------------------------------------
Copyright (C) 2001 - 2003 TheMedia, Dipl.-Ing Thomas Plänkers
http://www.themedia.at & http://www.oscommerce.at
All rights reserved.
This program is free software licensed under the GNU General Public License (GPL).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_cod_fee {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_cod_fee';
$this->title = $aLang['module_order_total_cod_title'];
$this->description = $aLang['module_order_total_cod_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_COD_STATUS') && (MODULE_ORDER_TOTAL_COD_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_COD_SORT_ORDER') ? MODULE_ORDER_TOTAL_COD_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies, $cod_cost, $cod_country;
if (MODULE_ORDER_TOTAL_COD_STATUS == 'true') {
//Will become true, if cod can be processed.
$cod_country = FALSE;
//check if payment method is cod. If yes, check if cod is possible.
if ($_SESSION['payment'] == 'cod') {
//process installed shipping modules
if ($_SESSION['shipping']['id'] == 'flat_flat') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
if ($_SESSION['shipping']['id'] == 'item_item') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
if ($_SESSION['shipping']['id'] == 'table_table') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
if ($_SESSION['shipping']['id'] == 'zones_zones') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
if ($_SESSION['shipping']['id'] == 'ap_ap') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP);
if ($_SESSION['shipping']['id'] == 'dp_dp') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP);
if ($_SESSION['shipping']['id'] == 'chp_ECO') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
if ($_SESSION['shipping']['id'] == 'chp_PRI') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
if ($_SESSION['shipping']['id'] == 'chp_URG') $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_CHP);
for ($i = 0; $i < count($cod_zones); $i++) {
if ($cod_zones[$i] == $oOrder->billing['country']['iso_code_2']) {
$cod_cost = $cod_zones[$i + 1];
$cod_country = TRUE;
//print('match' . $i . ': ' . $cod_cost);
break;
} elseif ($cod_zones[$i] == '00') {
$cod_cost = $cod_zones[$i + 1];
$cod_country = TRUE;
//print('match' . $i . ': ' . $cod_cost);
break;
} else {
//print('no match');
}
$i++;
}
} else {
//COD selected, but no shipping module which offers COD
}
if ($cod_country) {
if (MODULE_ORDER_TOTAL_COD_TAX_CLASS > 0) {
$cod_tax = oos_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
// $cod_tax_description = oos_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
$cod_tax_description = oos_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
$oOrder->info['tax'] += oos_calculate_tax($cod_cost, $cod_tax);
$oOrder->info['tax_groups']["$cod_tax_description"] += oos_calculate_tax($cod_cost, $cod_tax);
$oOrder->info['total'] += $cod_cost + oos_calculate_tax($cod_cost, $cod_tax);
$this->output[] = array('title' => $this->title . ':',
'text' => $oCurrencies->format(oos_add_tax($cod_cost, $cod_tax), true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => oos_add_tax($cod_cost, $cod_tax));
} else {
$oOrder->info['total'] += $cod_cost;
$this->output[] = array('title' => $this->title . ':',
'text' => $oCurrencies->format($cod_cost, true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => $cod_cost);
}
} else {
//Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
// as well as countries who do not have cod
// $this->output[] = array('title' => $this->title . ':',
// 'text' => 'No COD for this module.',
// 'value' => '');
}
}
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_COD_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_COD_STATUS', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'MODULE_ORDER_TOTAL_COD_TAX_CLASS');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_STATUS', 'true', '6', '0','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_SORT_ORDER', '6', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'AT:3.00,DE:3.58,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'AT:3.00,DE:3.58,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'AT:3.00,DE:3.58,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'CA:4.50,US:3.00,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_AP', 'AT:3.63,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_DP', 'DE:3.58,00:9.99', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_FEE_CHP', 'CH:15.00,00:15.00', '6', '0', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_COD_TAX_CLASS', '0', '6', '0', 'oos_cfg_get_tax_class_title', 'oos_cfg_pull_down_tax_classes(', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,592 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_coupon.php,v 1.4 2007/12/23 22:59:27 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_coupon.php,v 1.1.2.36 2003/05/14 22:52:59 wilt
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_coupon {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_coupon';
$this->header = $aLang['module_order_total_coupon_header'];
$this->title =$aLang['module_order_total_coupon_title'];
$this->description = $aLang['module_order_total_coupon_description'];
$this->user_prompt = '';
$this->enabled = (defined('MODULE_ORDER_TOTAL_COUPON_STATUS') && (MODULE_ORDER_TOTAL_COUPON_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_COUPON_SORT_ORDER') ? MODULE_ORDER_TOTAL_COUPON_SORT_ORDER : null);
$this->include_shipping = (defined('MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING') ? MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING : null);
$this->include_tax = (defined('MODULE_ORDER_TOTAL_COUPON_INC_TAX') ? MODULE_ORDER_TOTAL_COUPON_INC_TAX : null);
$this->calculate_tax = (defined('MODULE_ORDER_TOTAL_COUPON_CALC_TAX') ? MODULE_ORDER_TOTAL_COUPON_CALC_TAX : null);
$this->tax_class = (defined('MODULE_ORDER_TOTAL_COUPON_TAX_CLASS') ? MODULE_ORDER_TOTAL_COUPON_TAX_CLASS : null);
$this->credit_class = TRUE;
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
$order_total = $this->get_order_total();
$od_amount = $this->calculate_credit($order_total);
$this->deduction = $od_amount;
if ($this->calculate_tax != 'none') {
$tod_amount = $this->calculate_tax_deduction($order_total, $this->deduction, $this->calculate_tax);
}
if ($od_amount > 0) {
$oOrder->info['total'] = $oOrder->info['total'] - $od_amount;
$this->output[] = array('title' => '<font color="#FF0000">' . $this->title . ':' . $this->coupon_code .':</font>',
'text' => '<strong><font color="#FF0000"> - ' . $oCurrencies->format($od_amount) . '</font></strong>',
'value' => $od_amount);
}
}
function selection_test() {
return FALSE;
}
function pre_confirmation_check($order_total) {
return $this->calculate_credit($order_total);
}
function use_credit_amount() {
return $output_string;
}
function credit_selection() {
global $aLang;
global $oCurrencies;
$sTheme = oos_var_prep_for_os($_SESSION['theme']);
$sLanguage = isset($_SESSION['language']) ? $_SESSION['language'] : DEFAULT_LANGUAGE;
$image_submit = '<input type="image" name="submit_redeem" onClick="submitFunction()" src="' . 'themes/' . $sTheme . '/images/buttons/' . $sLanguage . '/redeem.gif" border="0" alt="' . $aLang['image_button_redeem_voucher'] . '" title = "' . $aLang['image_button_redeem_voucher'] . '">';
$selection_string = '';
$selection_string .= '<tr>' . "\n";
$selection_string .= ' <td width="10"></td>';
$selection_string .= ' <td class="main">' . "\n";
$selection_string .= $aLang['text_enter_coupon_code'] . oos_draw_input_field('gv_redeem_code') . '</td>';
$selection_string .= ' <td align="right">' . $image_submit . '</td>';
$selection_string .= ' <td width="10"></td>';
$selection_string .= '</tr>' . "\n";
return $selection_string;
}
function collect_posts() {
global $oCurrencies, $aLang;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$aContents = oos_get_content();
if ($_POST['gv_redeem_code']) {
// get some info from the coupon table
$couponstable = $oostable['coupons'];
$sql = "SELECT coupon_id, coupon_amount, coupon_type, coupon_minimum_order,
uses_per_coupon, uses_per_user, restrict_to_products,
restrict_to_categories
FROM $couponstable
WHERE coupon_code = '" . oos_db_input($_POST['gv_redeem_code']). "'
AND coupon_active = 'Y'";
$coupon_query = $dbconn->Execute($sql);
$coupon_result = $coupon_query->fields;
if ($coupon_result['coupon_type'] != 'G') {
if ($coupon_query->RecordCount() == 0) {
oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_no_invalid_redeem_coupon'])));
}
$couponstable = $oostable['coupons'];
$sql = "SELECT coupon_start_date
FROM $couponstable
WHERE coupon_start_date <= now()
AND coupon_code= '" . oos_db_input($_POST['gv_redeem_code']) . "'";
$date_query = $dbconn->Execute($sql);
if ($date_query->RecordCount() == 0) {
oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_invalid_startdate_coupon'])));
}
$couponstable = $oostable['coupons'];
$sql = "SELECT coupon_expire_date
FROM $couponstable
WHERE coupon_expire_date >= now()
AND coupon_code= '" . oos_db_input($_POST['gv_redeem_code']) . "'";
$date_query = $dbconn->Execute($sql);
if ($date_query->RecordCount() == 0) {
oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_invalid_finisdate_coupon'])));
}
$coupon_redeem_tracktable = $oostable['coupon_redeem_track'];
$sql = "SELECT coupon_id
FROM $coupon_redeem_tracktable
WHERE coupon_id = '" . $coupon_result['coupon_id']."'";
$coupon_count = $dbconn->Execute($sql);
$coupon_redeem_tracktable = $oostable['coupon_redeem_track'];
$sql = "SELECT coupon_id
FROM $coupon_redeem_tracktable
WHERE coupon_id = '" . $coupon_result['coupon_id']."'
AND customer_id = '" . intval($_SESSION['customer_id']) . "'";
$coupon_count_customer = $dbconn->Execute($sql);
if ($coupon_count->RecordCount()>=$coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) {
oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_invalid_uses_coupon'] . $coupon_result['uses_per_coupon'] . $aLang['times'] )));
}
if ($coupon_count_customer->RecordCount()>=$coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) {
oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_invalid_uses_user_coupon'] . $coupon_result['uses_per_user'] . $aLang['times'] )));
}
if ($coupon_result['coupon_type'] == 'S') {
$coupon_amount = $oOrder->info['shipping_cost'];
} else {
$coupon_amount = $oCurrencies->format($coupon_result['coupon_amount']) . ' ';
}
if ($coupon_result['type']=='P') $coupon_amount = $coupon_result['coupon_amount'] . '% ';
if ($coupon_result['coupon_minimum_order']>0) $coupon_amount .= 'on orders greater than ' . $coupon_result['coupon_minimum_order'];
$_SESSION['cc_id'] = $coupon_result['coupon_id'];
}
if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) oos_redirect(oos_href_link($aContents['checkout_payment'], 'error_message=' . urlencode($aLang['error_no_invalid_redeem_coupon'])));
}
}
function calculate_credit($amount) {
global $oOrder;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$od_amount = 0;
if (isset($_SESSION['cc_id'])) {
$cc_id = intval($_SESSION['cc_id']);
$couponstable = $oostable['coupons'];
$coupon_query = $dbconn->Execute("SELECT coupon_code FROM $couponstable WHERE coupon_id = '" . intval($cc_id) . "'");
if ($coupon_query->RecordCount() !=0 ) {
$coupon_result = $coupon_query->fields;
$this->coupon_code = $coupon_result['coupon_code'];
$couponstable = $oostable['coupons'];
$coupon_get = $dbconn->Execute("SELECT coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type FROM $couponstable WHERE coupon_code = '". $coupon_result['coupon_code'] . "'");
$get_result = $coupon_get->fields;
$c_deduct = $get_result['coupon_amount'];
if ($get_result['coupon_type'] == 'S') $c_deduct = $oOrder->info['shipping_cost'];
if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) {
if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) {
for ($i=0; $i<count($oOrder->products); $i++) {
if ($get_result['restrict_to_products']) {
$pr_ids = preg_split("/[,]/", $get_result['restrict_to_products']);
for ($ii = 0; $ii < count($pr_ids); $ii++) {
if ($pr_ids[$ii] == oos_get_product_id($oOrder->products[$i]['id'])) {
if ($get_result['coupon_type'] == 'P') {
$od_amount = round($amount*10)/10*$c_deduct/100;
$pr_c = $oOrder->products[$i]['final_price']*$oOrder->products[$i]['qty'];
$pod_amount = round($pr_c*10)/10*$c_deduct/100;
} else {
$od_amount = $c_deduct;
}
}
}
} else {
$cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']);
for ($i=0; $i<count($oOrder->products); $i++) {
$my_path = oos_get_product_path(oos_get_product_id($oOrder->products[$i]['id']));
$sub_cat_ids = preg_split("/[_]/", $my_path);
for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
for ($ii = 0; $ii < count($cat_ids); $ii++) {
if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
if ($get_result['coupon_type'] == 'P') {
$od_amount = round($amount*10)/10*$c_deduct/100;
$pr_c = $oOrder->products[$i]['final_price']*$oOrder->products[$i]['qty'];
$pod_amount = round($pr_c*10)/10*$c_deduct/100;
} else {
$od_amount = $c_deduct;
}
}
}
}
}
}
}
} else {
if ($get_result['coupon_type'] !='P') {
$od_amount = $c_deduct;
} else {
$od_amount = $amount * $get_result['coupon_amount'] / 100;
}
}
}
}
if ($od_amount>$amount) $od_amount = $amount;
}
return $od_amount;
}
function calculate_tax_deduction($amount, $od_amount, $method) {
global $oOrder, $cc_id;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$cc_id = intval($_SESSION['cc_id']);
$couponstable = $oostable['coupons'];
$coupon_query = $dbconn->Execute("SELECT coupon_code FROM $couponstable WHERE coupon_id = '" . intval($cc_id) . "'");
if ($coupon_query->RecordCount() !=0 ) {
$coupon_result = $coupon_query->fields;
$coupon_get = $dbconn->Execute("SELECT coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type FROM " . $oostable['coupons'] . " WHERE coupon_code = '". $coupon_result['coupon_code'] . "'");
$get_result = $coupon_get->fields;
if ($get_result['coupon_type'] != 'S') {
if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) {
// What to do here.
// Loop through all products and build a list of all product_ids, price, tax class
// at the same time create total net amount.
// then
// for percentage discounts. simply reduce tax group per product by discount percentage
// or
// for fixed payment amount
// calculate ratio based on total net
// for each product reduce tax group per product by ratio amount.
$products = $_SESSION['cart']->get_products();
for ($i=0; $i<count($products); $i++) {
$t_prid = oos_get_product_id($products[$i]['id']);
$productstable = $oostable['products'];
$cc_query = $dbconn->Execute("SELECT products_tax_class_id FROM $productstable WHERE products_id = '" . (int)$t_prid . "'");
$cc_result = $cc_query->fields;
$valid_product = FALSE;
if ($get_result['restrict_to_products']) {
$pr_ids = preg_split("/[,]/", $get_result['restrict_to_products']);
for ($p = 0; $p < count($pr_ids); $p++) {
if ($pr_ids[$p] == $t_prid) $valid_product = TRUE;
}
}
if ($get_result['restrict_to_categories']) {
$cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']);
for ($c = 0; $c < count($cat_ids); $c++) {
$products_to_categoriestable = $oostable['products_to_categories'];
$cat_query = $dbconn->Execute("SELECT products_id FROM $products_to_categoriestable WHERE products_id = '" . (int)$products_id . "' AND categories_id = '" . (int)$cat_ids[$i] . "'");
if ($cat_query->RecordCount() !=0 ) $valid_product = TRUE;
}
}
if ($valid_product) {
$valid_array[] = array('product_id' => $t_prid,
'products_price' => $products[$i]['final_price'] * $products[$i]['quantity'],
'products_tax_class' => $cc_result['products_tax_class_id']);
$total_price += $products[$i]['final_price'] * $products[$i]['quantity'];
}
}
if ($valid_product) {
if ($get_result['coupon_type'] == 'P') {
$ratio = $get_result['coupon_amount']/100;
} else {
$ratio = $od_amount / $total_price;
}
if ($get_result['coupon_type'] == 'S') $ratio = 1;
if ($method=='Credit Note') {
$tax_rate = oos_get_tax_rate($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tax_desc = oos_get_tax_description($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
if ($get_result['coupon_type'] == 'P') {
$tod_amount = $od_amount / (100 + $tax_rate)* $tax_rate;
} else {
$tod_amount = $oOrder->info['tax_groups'][$tax_desc] * $od_amount/100;
}
$oOrder->info['tax_groups'][$tax_desc] -= $tod_amount;
$oOrder->info['total'] -= $tod_amount;
} else {
for ($p=0; $p<count($valid_array); $p++) {
$tax_rate = oos_get_tax_rate($valid_array[$p]['products_tax_class'], $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tax_desc = oos_get_tax_description($valid_array[$p]['products_tax_class'], $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
if ($tax_rate > 0) {
$tod_amount[$tax_desc] += ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio;
$oOrder->info['tax_groups'][$tax_desc] -= ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio;
$oOrder->info['total'] -= ($valid_array[$p]['products_price'] * $tax_rate)/100 * $ratio;
}
}
}
}
} else {
if ($get_result['coupon_type'] =='F') {
$tod_amount = 0;
if ($method=='Credit Note') {
$tax_rate = oos_get_tax_rate($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tax_desc = oos_get_tax_description($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tod_amount = $od_amount / (100 + $tax_rate)* $tax_rate;
$oOrder->info['tax_groups'][$tax_desc] -= $tod_amount;
} else {
$ratio1 = $od_amount/$amount;
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$tax_rate = oos_get_tax_rate_from_desc($key);
$net = $tax_rate * $oOrder->info['tax_groups'][$key];
if ($net>0) {
$god_amount = $oOrder->info['tax_groups'][$key] * $ratio1;
$tod_amount += $god_amount;
$oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount;
}
}
}
$oOrder->info['total'] -= $tod_amount;
}
if ($get_result['coupon_type'] =='P') {
$tod_amount=0;
if ($method=='Credit Note') {
$tax_desc = oos_get_tax_description($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tod_amount = $oOrder->info['tax_groups'][$tax_desc] * $od_amount/100;
$oOrder->info['tax_groups'][$tax_desc] -= $tod_amount;
} else {
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$god_amout=0;
$tax_rate = oos_get_tax_rate_from_desc($key);
$net = $tax_rate * $oOrder->info['tax_groups'][$key];
if ($net>0) {
$god_amount = $oOrder->info['tax_groups'][$key] * $get_result['coupon_amount']/100;
$tod_amount += $god_amount;
$oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount;
}
}
}
$oOrder->info['tax'] -= $tod_amount;
}
}
}
}
return $tod_amount;
}
function update_credit_account($i) {
return FALSE;
}
function apply_credit() {
global $insert_id;
$cc_id = intval($_SESSION['cc_id']);
$remote_addr = oos_server_get_remote();
if ($this->deduction !=0) {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$coupon_redeem_tracktable = $oostable['coupon_redeem_track'];
$dbconn->Execute("INSERT INTO $coupon_redeem_tracktable (coupon_id, redeem_date, redeem_ip, customer_id, order_id) VALUES ('" . oos_db_input($cc_id) . "', now(), '" . oos_db_input($remote_addr) . "', '" . intval($_SESSION['customer_id']) . "', '" . intval($insert_id) . "')");
}
unset($_SESSION['cc_id']);
}
function get_order_total() {
global $oOrder;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$cc_id = $_SESSION['cc_id'];
$order_total = $oOrder->info['total'];
// Check if gift voucher is in cart and adjust total
$products = $_SESSION['cart']->get_products();
for ($i=0; $i<count($products); $i++) {
$t_prid = oos_get_product_id($products[$i]['id']);
$productstable = $oostable['products'];
$gv_query = $dbconn->Execute("SELECT products_price, products_tax_class_id, products_model FROM $productstable WHERE products_id = '" . intval($t_prid) . "'");
$gv_result = $gv_query->fields;
if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) {
$qty = $_SESSION['cart']->get_quantity($t_prid);
$products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']);
if ($this->include_tax =='false') {
$gv_amount = $gv_result['products_price'] * $qty;
} else {
$gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
}
$order_total=$order_total - $gv_amount;
}
}
if ($this->include_tax == 'false') $order_total=$order_total-$oOrder->info['tax'];
if ($this->include_shipping == 'false') $order_total=$order_total-$oOrder->info['shipping_cost'];
// OK thats fine for global coupons but what about restricted coupons
// where you can only redeem against certain products/categories.
// and I though this was going to be easy !!!
$couponstable = $oostable['coupons'];
$coupon_query=$dbconn->Execute("SELECT coupon_code FROM $couponstable WHERE coupon_id = '" . oos_db_input($cc_id) . "'");
if ($coupon_query->RecordCount() !=0) {
$coupon_result = $coupon_query->fields;
$couponstable = $oostable['coupons'];
$coupon_get = $dbconn->Execute("SELECT coupon_amount, coupon_minimum_order,restrict_to_products,restrict_to_categories, coupon_type FROM $couponstable WHERE coupon_code = '" . $coupon_result['coupon_code'] . "'");
$get_result = $coupon_get->fields;
$in_cat = TRUE;
if ($get_result['restrict_to_categories']) {
$cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']);
$in_cat=false;
for ($i = 0; $i < count($cat_ids); $i++) {
if (is_array($this->contents)) {
reset($this->contents);
foreach ( array_keys($this->contents) as $products_id ) {
$products_to_categoriestable = $oostable['products_to_categories'];
$cat_query = $dbconn->Execute("SELECT products_id FROM $products_to_categoriestable WHERE products_id = '" . (int)$products_id . "' AND categories_id = '" . (int)$cat_ids[$i] . "'");
if ($cat_query->RecordCount() !=0 ) {
$in_cat = TRUE;
$total_price += $this->get_product_price($products_id);
}
}
}
}
}
$in_cart = TRUE;
if ($get_result['restrict_to_products']) {
$pr_ids = preg_split("/[,]/", $get_result['restrict_to_products']);
$in_cart=false;
$products_array = $_SESSION['cart']->get_products();
for ($i = 0; $i < count($pr_ids); $i++) {
for ($ii = 1; $ii<=count($products_array); $ii++) {
if (oos_get_product_id($products_array[$ii-1]['id']) == $pr_ids[$i]) {
$in_cart=true;
$total_price += $this->get_product_price($products_array[$ii-1]['id']);
}
}
}
$order_total = $total_price;
}
}
return $order_total;
}
function get_product_price($product_id) {
global $oOrder;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$products_id = oos_get_product_id($product_id);
// products price
$qty = $_SESSION['cart']->contents[$product_id]['qty'];
$productstable = $oostable['products'];
$product_query = $dbconn->Execute("SELECT products_id, products_price, products_tax_class_id, products_weight FROM $productstable WHERE products_id='" . (int)$product_id . "'");
if ($product = $product_query->fields) {
$prid = $product['products_id'];
$products_tax = oos_get_tax_rate($product['products_tax_class_id']);
$products_price = $product['products_price'];
$specialstable = $oostable['specials'];
$specials_query = $dbconn->Execute("SELECT specials_new_products_price FROM $specialstable WHERE products_id = '" . (int)$prid . "' AND status = '1'");
if ($specials_query->RecordCount()) {
$specials = $specials_query->fields;
$products_price = $specials['specials_new_products_price'];
}
if ($this->include_tax == 'true') {
$total_price += ($products_price + oos_calculate_tax($products_price, $products_tax)) * $qty;
} else {
$total_price += $products_price * $qty;
}
// attributes price
if (isset($_SESSION['cart']->contents[$product_id]['attributes'])) {
reset($_SESSION['cart']->contents[$product_id]['attributes']);
foreach($_SESSION['cart']->contents[$product_id]['attributes'] as $option => $value) {
$products_attributestable = $oostable['products_attributes'];
$attribute_price_query = $dbconn->Execute("SELECT options_values_price, price_prefix FROM $products_attributestable WHERE products_id = '" . (int)$prid . "' AND options_id = '" . oos_db_input($option) . "' AND options_values_id = '" . oos_db_input($value) . "'");
$attribute_price = $attribute_price_query->fields;
if ($attribute_price['price_prefix'] == '+') {
if ($this->include_tax == 'true') {
$total_price += $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax));
} else {
$total_price += $qty * ($attribute_price['options_values_price']);
}
} else {
if ($this->include_tax == 'true') {
$total_price -= $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax));
} else {
$total_price -= $qty * ($attribute_price['options_values_price']);
}
}
}
}
}
if ($this->include_shipping == 'true') $total_price += $oOrder->info['shipping_cost'];
return $total_price;
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_COUPON_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_COUPON_STATUS', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', '8', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'true', '6', '5', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'true', '6', '6','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'None', '6', '7','oos_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_COUPON_TAX_CLASS', '0', '6', '0', 'oos_cfg_get_tax_class_title', 'oos_cfg_pull_down_tax_classes(', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,417 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_gv.php,v 1.2 2007/12/23 22:59:27 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_gv.php,v 1.4.2.12 2003/05/14 22:52:59 wilt
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_gv {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_gv';
$this->title = $aLang['module_order_total_gv_title'];
$this->header = $aLang['module_order_total_gv_header'];
$this->description = $aLang['module_order_total_gv_description'];
$this->user_prompt = $aLang['module_order_total_gv_user_prompt'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_GV_STATUS') && (MODULE_ORDER_TOTAL_GV_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_GV_SORT_ORDER') ? MODULE_ORDER_TOTAL_GV_SORT_ORDER : null);
$this->include_shipping = (defined('MODULE_ORDER_TOTAL_GV_INC_SHIPPING') ? MODULE_ORDER_TOTAL_GV_INC_SHIPPING : null);
$this->include_tax = (defined('MODULE_ORDER_TOTAL_GV_INC_TAX') ? MODULE_ORDER_TOTAL_GV_INC_TAX : null);
$this->calculate_tax = (defined('MODULE_ORDER_TOTAL_GV_CALC_TAX') ? MODULE_ORDER_TOTAL_GV_CALC_TAX : null);
$this->credit_tax = (defined('MODULE_ORDER_TOTAL_GV_CREDIT_TAX') ? MODULE_ORDER_TOTAL_GV_CREDIT_TAX : null);
$this->tax_class = (defined('MODULE_ORDER_TOTAL_GV_TAX_CLASS') ? MODULE_ORDER_TOTAL_GV_TAX_CLASS : null);
$this->show_redeem_box = (defined('MODULE_ORDER_TOTAL_GV_REDEEM_BOX') ? MODULE_ORDER_TOTAL_GV_REDEEM_BOX : null);
$this->credit_class = TRUE;
$this->checkbox = $this->user_prompt . '<input type="checkbox" onClick="submitFunction()" name="' . 'c' . $this->code . '">';
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
if (isset ($_SESSION['cot_gv']) && $_SESSION['cot_gv'] == TRUE) {
$order_total = $this->get_order_total();
$od_amount = $this->calculate_credit($order_total);
if ($this->calculate_tax != "none") {
$tod_amount = $this->calculate_tax_deduction($order_total, $od_amount, $this->calculate_tax);
$od_amount = $this->calculate_credit($order_total);
}
$this->deduction = $od_amount;
$oOrder->info['total'] = $oOrder->info['total'] - $od_amount;
if ($od_amount > 0) {
$this->output[] = array('title' => '<font color="#FF0000">' . $this->title . ':</font>',
'text' => '<strong><font color="#FF0000"> - ' . $oCurrencies->format($od_amount) . '</font></strong>',
'value' => $sod_amount);
}
}
}
function selection_test() {
if ($this->user_has_gv_account($_SESSION['customer_id'])) {
return true;
} else {
return FALSE;
}
}
function pre_confirmation_check($order_total) {
$gv_payment_amount = $this->calculate_credit($order_total);
return $gv_payment_amount;
}
function use_credit_amount() {
$_SESSION['cot_gv'] = FALSE;
$output_string = '';
if ($this->selection_test()) {
$output_string .= ' <td colspan="2" align="right" class="main">';
$output_string .= '<strong>' . $this->checkbox . '</strong>' . '</td>' . "\n";
}
return $output_string;
}
function update_credit_account($i) {
global $oOrder, $insert_id;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
if (preg_match('/^GIFT/', addslashes($oOrder->products[$i]['model']))) {
$gv_order_amount = ($oOrder->products[$i]['final_price'] * $oOrder->products[$i]['qty']);
if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $oOrder->products[$i]['tax']) / 100;
$gv_order_amount = $gv_order_amount * 100 / 100;
if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
// GV_QUEUE is true so release amount to account immediately
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_query = $dbconn->Execute("SELECT amount FROM $coupon_gv_customertable WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
$customer_gv = FALSE;
$total_gv_amount = 0;
if ($gv_result = $gv_query->fields) {
$total_gv_amount = $gv_result['amount'];
$customer_gv = TRUE;
}
$total_gv_amount = $total_gv_amount + $gv_order_amount;
if ($customer_gv) {
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_update=$dbconn->Execute("UPDATE $coupon_gv_customertable
SET amount = '" . oos_db_input($total_gv_amount) . "'
WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
} else {
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_insert=$dbconn->Execute("INSERT INTO $coupon_gv_customertable
(customer_id,
amount) VALUES ('" . intval($_SESSION['customer_id']) . "',
'" . oos_db_input($total_gv_amount) . "')");
}
} else {
// GV_QUEUE is true - so queue the gv for release by store owner
$remote_addr = oos_server_get_remote();
$coupon_gv_queuetable = $oostable['coupon_gv_queue'];
$gv_insert=$dbconn->Execute("INSERT INTO $coupon_gv_queuetable
(customer_id,
order_id,
amount,
date_created,
ipaddr) VALUES ('" . intval($_SESSION['customer_id']) . "',
'" . intval($insert_id) . "',
'" . oos_db_input($gv_order_amount) . "',
now(),
'" . oos_db_input($remote_addr) . "')");
}
}
}
function credit_selection() {
global $oCurrencies, $aLang;
$selection_string = '';
$sTheme = oos_var_prep_for_os($_SESSION['theme']);
$sLanguage = isset($_SESSION['language']) ? $_SESSION['language'] : DEFAULT_LANGUAGE;
$image_submit = '<input type="image" name="submit_redeem" onClick="submitFunction()" src="themes/' . $sTheme . '/images/buttons/' . $sLanguage . '/redeem.gif" border="0" alt="' . $aLang['image_button_redeem_voucher'] . '" title = "' . $aLang['image_button_redeem_voucher'] . '">';
$selection_string = '';
$selection_string .= '<tr>' . "\n";
$selection_string .= ' <td width="10"></td>';
$selection_string .= ' <td class="main">' . "\n";
$selection_string .= $aLang['text_enter_gv_code'] . oos_draw_input_field('gv_redeem_code') . '</td>';
$selection_string .= ' <td align="right">' . $image_submit . '</td>';
$selection_string .= ' <td width="10"></td>';
$selection_string .= '</tr>' . "\n";
return $selection_string;
}
function apply_credit() {
global $oOrder, $coupon_no;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
if (isset ($_SESSION['cot_gv']) && $_SESSION['cot_gv'] == TRUE) {
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_query = $dbconn->Execute("SELECT amount FROM $coupon_gv_customertable WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
$gv_result = $gv_query->fields;
$gv_payment_amount = $this->deduction;
$gv_amount = $gv_result['amount'] - $gv_payment_amount;
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_update = $dbconn->Execute("UPDATE $coupon_gv_customertable
SET amount = '" . $gv_amount . "'
WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
}
return $gv_payment_amount;
}
function collect_posts() {
global $oCurrencies, $oMessage, $coupon_no, $aLang;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$aContents = oos_get_content();
if ($_POST['gv_redeem_code']) {
$couponstable = $oostable['coupons'];
$gv_query = $dbconn->Execute("SELECT coupon_id, coupon_type, coupon_amount FROM $couponstable WHERE coupon_code = '" . oos_db_input($_POST['gv_redeem_code']) . "'");
$gv_result = $gv_query->fields;
if ($gv_query->RecordCount() != 0) {
$coupon_redeem_tracktable = $oostable['coupon_redeem_track'];
$redeem_query = $dbconn->Execute("SELECT * FROM $coupon_redeem_tracktable WHERE coupon_id = '" . $gv_result['coupon_id'] . "'");
if ( ($redeem_query->RecordCount() != 0) && ($gv_result['coupon_type'] == 'G') ) {
$oMessage->add_session('checkout_payment', $aLang['error_no_invalid_redeem_gv'], 'error');
oos_redirect(oos_href_link($aContents['checkout_payment']));
}
}
if ($gv_result['coupon_type'] == 'G') {
$gv_amount = $gv_result['coupon_amount'];
// Things to set
// ip address of claimant
// customer id of claimant
// date
// redemption flag
// now update customer account with gv_amount
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_amount_query = $dbconn->Execute("SELECT amount FROM $coupon_gv_customertable WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
$customer_gv = FALSE;
$total_gv_amount = $gv_amount;
if ($gv_amount_result = $gv_amount_query->fields) {
$total_gv_amount = $gv_amount_result['amount'] + $gv_amount;
$customer_gv = TRUE;
}
$couponstable = $oostable['coupons'];
$gv_update = $dbconn->Execute("UPDATE $couponstable
SET coupon_active = 'N'
WHERE coupon_id = '" . $gv_result['coupon_id'] . "'");
$remote_addr = oos_server_get_remote();
$coupon_redeem_tracktable = $oostable['coupon_redeem_track'];
$gv_redeem = $dbconn->Execute("INSERT INTO $coupon_redeem_tracktable
(coupon_id,
customer_id,
redeem_date,
redeem_ip) VALUES ('" . $gv_result['coupon_id'] . "',
'" . intval($_SESSION['customer_id']) . "',
now(),
'" . oos_db_input($remote_addr) . "')");
if ($customer_gv) {
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
// already has gv_amount so update
$gv_update = $dbconn->Execute("UPDATE $coupon_gv_customertable
SET amount = '" . $total_gv_amount . "'
WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'");
} else {
// no gv_amount so insert
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$gv_insert = $dbconn->Execute("INSERT INTO $coupon_gv_customertable
(customer_id,
amount) VALUES ('" . intval($_SESSION['customer_id']) . "',
'" . $total_gv_amount . "')");
}
$oMessage->add_session('checkout_payment', $aLang['error_redeemed_amount'] . $oCurrencies->format($gv_amount), 'error');
oos_redirect(oos_href_link($aContents['checkout_payment']));
}
}
if ($_POST['submit_redeem_x'] && $gv['coupon_type'] == 'G'){
$oMessage->add_session('checkout_payment', $aLang['error_no_redeem_code'], 'error');
}
if ($oMessage->size('checkout_payment') > 0) {
oos_redirect(oos_href_link($aContents['checkout_payment']));
}
}
function calculate_credit($amount) {
global $oOrder;
$gv_payment_amount = 0;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$query = "SELECT amount
FROM $coupon_gv_customertable
WHERE customer_id = '" . intval($_SESSION['customer_id']) . "'";
$gv_query = $dbconn->Execute($query);
if ($gv_query->RecordCount()) {
$gv_result = $gv_query->fields;
$gv_payment_amount = $gv_result['amount'];
$save_total_cost = $amount;
$full_cost = $save_total_cost - $gv_payment_amount;
if ($full_cost < 0) {
$full_cost = 0;
$gv_payment_amount = $save_total_cost;
}
}
return round($gv_payment_amount,2);
}
function calculate_tax_deduction($amount, $od_amount, $method) {
global $oOrder;
switch ($method) {
case 'Standard':
$ratio1 = round($od_amount / $amount,2);
$tod_amount = 0;
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$tax_rate = oos_get_tax_rate_from_desc($key);
$total_net += $tax_rate * $oOrder->info['tax_groups'][$key];
}
if ($od_amount > $total_net) $od_amount = $total_net;
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$tax_rate = oos_get_tax_rate_from_desc($key);
$net = $tax_rate * $oOrder->info['tax_groups'][$key];
if ($net > 0) {
$god_amount = $oOrder->info['tax_groups'][$key] * $ratio1;
$tod_amount += $god_amount;
$oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount;
}
}
$oOrder->info['tax'] -= $tod_amount;
$oOrder->info['total'] -= $tod_amount;
break;
case 'Credit Note':
$tax_rate = oos_get_tax_rate($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tax_desc = oos_get_tax_description($this->tax_class, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tod_amount = $this->deduction / (100 + $tax_rate)* $tax_rate;
$oOrder->info['tax_groups'][$tax_desc] -= $tod_amount;
// $oOrder->info['total'] -= $tod_amount;
break;
default:
}
return $tod_amount;
}
function user_has_gv_account($c_id) {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
$query = "SELECT amount
FROM $coupon_gv_customertable
WHERE customer_id = '" . oos_db_input($c_id) . "'";
$gv_result = $dbconn->Execute($query);
if ($gv_result->fields['amount']>0) {
return true;
}
return FALSE;
}
function get_order_total() {
global $oOrder;
$order_total = $oOrder->info['total'];
if ($this->include_tax == 'false') $order_total = $order_total - $oOrder->info['tax'];
if ($this->include_shipping == 'false') $order_total = $order_total - $oOrder->info['shipping_cost'];
return $order_total;
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_GV_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_GV_SORT_ORDER', 'MODULE_ORDER_TOTAL_GV_QUEUE', 'MODULE_ORDER_TOTAL_GV_INC_SHIPPING', 'MODULE_ORDER_TOTAL_GV_INC_TAX', 'MODULE_ORDER_TOTAL_GV_CALC_TAX', 'MODULE_ORDER_TOTAL_GV_TAX_CLASS', 'MODULE_ORDER_TOTAL_GV_CREDIT_TAX');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("UPDATE $configurationtable SET coupon_active = 'true' WHERE configuration_key = '" . oos_db_input(MODULE_ORDER_TOTAL_GV_STATUS) . "'");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_GV_SORT_ORDER', '9', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_GV_QUEUE', 'true', '6', '3','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_GV_INC_SHIPPING', 'true', '6', '5', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_GV_INC_TAX', 'true', '6', '6','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_GV_CALC_TAX', 'None', '6', '7','oos_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_GV_TAX_CLASS', '0', '6', '0', 'oos_cfg_get_tax_class_title', 'oos_cfg_pull_down_tax_classes(', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) VALUES ('MODULE_ORDER_TOTAL_GV_CREDIT_TAX', 'false', '6', '8','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("UPDATE $configurationtable SET coupon_active = 'false' WHERE configuration_key = '" . oos_db_input(MODULE_ORDER_TOTAL_GV_STATUS) . "'");
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,106 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_loworderfee.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_loworderfee.php,v 1.11 2003/02/14 06:03:32 hpdl
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_loworderfee {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_loworderfee';
$this->title = $aLang['module_order_total_loworderfee_title'];
$this->description = $aLang['module_order_total_loworderfee_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS') && (MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER') ? MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
case 'national':
if ($oOrder->delivery['country_id'] == STORE_COUNTRY) $pass = TRUE; break;
case 'international':
if ($oOrder->delivery['country_id'] != STORE_COUNTRY) $pass = TRUE; break;
case 'both':
$pass = TRUE; break;
default:
$pass = FALSE; break;
}
if ( ($pass == TRUE) && ( ($oOrder->info['total'] - $oOrder->info['shipping_cost']) < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) {
$tax = oos_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
// $tax_description = oos_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']);
$tax_description = oos_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
$oOrder->info['tax'] += oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
$oOrder->info['tax_groups']["$tax_description"] += oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
$oOrder->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax);
$this->output[] = array('title' => $this->title . ':',
'text' => $oCurrencies->format(oos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => oos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax));
}
}
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS');
}
return $this->_check;
}
function keys() {
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');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_SORT_ORDER', '2', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE', 'false', '6', '3', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER', '50', '6', '4', 'currencies->format', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_FEE', '5', '6', '5', 'currencies->format', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION', 'both', '6', '6', 'oos_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS', '0', '6', '7', 'oos_cfg_get_tax_class_title', 'oos_cfg_pull_down_tax_classes(', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,90 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_netto.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_netto.php,v 1.0.0.0 2004/03/07 19:30:00 Stephan Hilchenbach
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_netto {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_netto';
$this->title = $aLang['module_order_total_netto_title'];
$this->description = $aLang['module_order_total_netto_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_NETTO_STATUS') && (MODULE_ORDER_TOTAL_NETTO_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_NETTO_SORT_ORDER') ? MODULE_ORDER_TOTAL_NETTO_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies, $aLang;
$tax_total = 0;
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
// sum all tax values to calculate total tax:
if ($value > 0) $tax_total += $value;
}
// subtract total tax from total invoice amount to calculate net amount:
$netto = $oOrder->info['total']-$tax_total;
// output net amount:
$this->output[] = array('title' => '(' . $this->title . ':',
'text' => $oCurrencies->format($netto, true, $oOrder->info['currency'], $oOrder->info['currency_value']) . ')',
'value' => $netto);
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_NETTO_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_NETTO_STATUS', 'MODULE_ORDER_TOTAL_NETTO_SORT_ORDER');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_NETTO_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_NETTO_SORT_ORDER', '10', '6', '10', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,117 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_shipping.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_shipping.php,v 1.15 2003/02/07 22:01:57 dgw_
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_shipping {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_shipping';
$this->title = $aLang['module_order_total_shipping_title'];
$this->description = $aLang['module_order_total_shipping_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_SHIPPING_STATUS') && (MODULE_ORDER_TOTAL_SHIPPING_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER') ? MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies, $aUser;
if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
case 'national':
if ($oOrder->delivery['country_id'] == STORE_COUNTRY) $pass = TRUE; break;
case 'international':
if ($oOrder->delivery['country_id'] != STORE_COUNTRY) $pass = TRUE; break;
case 'both':
$pass = TRUE; break;
default:
$pass = FALSE; break;
}
if ( ($pass == TRUE) && ( ($oOrder->info['total'] - $oOrder->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
$oOrder->info['shipping_method'] = $this->title;
$oOrder->info['total'] -= $oOrder->info['shipping_cost'];
$oOrder->info['shipping_cost'] = 0;
}
}
$module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
if (oos_is_not_null($oOrder->info['shipping_method'])) {
if ($GLOBALS[$module]->tax_class > 0) {
$shipping_tax = oos_get_tax_rate($GLOBALS[$module]->tax_class, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
$shipping_tax_description = oos_get_tax_rate($GLOBALS[$module]->tax_class, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']);
$tax = oos_calculate_tax($oOrder->info['shipping_cost'], $shipping_tax);
if ($aUser['price_with_tax'] == 1) $oOrder->info['shipping_cost'] += $tax;
$oOrder->info['tax'] += $tax;
$oOrder->info['tax_groups']["$shipping_tax_description"] += $tax;
$oOrder->info['total'] += $tax;
}
$this->output[] = array('title' => $oOrder->info['shipping_method'] . ':',
'text' => $oCurrencies->format($oOrder->info['shipping_cost'], true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => $oOrder->info['shipping_cost']);
}
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_SHIPPING_STATUS');
}
return $this->_check;
}
function keys() {
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');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', '5', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', '6', '3', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (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())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', '6', '5', 'oos_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,78 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_subtotal.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_subtotal.php,v 1.7 2003/02/13 00:12:04 hpdl
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_subtotal {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_subtotal';
$this->title = $aLang['module_order_total_subtotal_title'];
$this->description = $aLang['module_order_total_subtotal_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_SUBTOTAL_STATUS') && (MODULE_ORDER_TOTAL_SUBTOTAL_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_SUBTOTAL_SORT_ORDER') ? MODULE_ORDER_TOTAL_SUBTOTAL_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
$this->output[] = array('title' => $this->title . ':',
'text' => $oCurrencies->format($oOrder->info['subtotal'], true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => $oOrder->info['subtotal']);
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_SUBTOTAL_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_SUBTOTAL_STATUS', 'MODULE_ORDER_TOTAL_SUBTOTAL_SORT_ORDER');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_SUBTOTAL_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_SUBTOTAL_SORT_ORDER', '1', '6', '2', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,90 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_tax.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_tax.php,v 1.14 2003/02/14 05:58:35 hpdl
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_tax {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang;
$this->code = 'ot_tax';
$this->title = $aLang['module_order_total_tax_title'];
$this->description = $aLang['module_order_total_tax_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_TAX_STATUS') && (MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_TAX_SORT_ORDER') ? MODULE_ORDER_TOTAL_TAX_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies, $aUser, $aLang;
reset($oOrder->info['tax_groups']);
if ($aUser['price_with_tax'] == 1) {
$info = $aLang['module_order_total_included_tax'];
} else {
$info = $aLang['module_order_total_ex_tax'];
}
foreach($oOrder->info['tax_groups'] as $key => $value) {
if ($value > 0) {
$this->output[] = array('title' => $info . $this->title . ' (' . number_format($key, 2) . '%):',
'text' => $oCurrencies->format($value, true, $oOrder->info['currency'], $oOrder->info['currency_value']),
'value' => $value);
}
}
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_TAX_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_TAX_STATUS', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_TAX_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_TAX_SORT_ORDER', '4', '6', '2', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,78 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_total.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_total.php,v 1.7 2003/02/13 00:12:04 hpdl
----------------------------------------------------------------------
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_total {
var $title, $output, $enabled = FALSE;
function __construct() {
global $aLang;
$this->code = 'ot_total';
$this->title = $aLang['module_order_total_total_title'];
$this->description = $aLang['module_order_total_total_description'];
$this->enabled = (defined('MODULE_ORDER_TOTAL_TOTAL_STATUS') && (MODULE_ORDER_TOTAL_TOTAL_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER') ? MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER : null);
$this->output = array();
}
function process() {
global $oOrder, $oCurrencies;
$this->output[] = array('title' => $this->title . ':',
'text' => '<strong>' . $oCurrencies->format($oOrder->info['total'], true, $oOrder->info['currency'], $oOrder->info['currency_value']) . '</strong>',
'value' => $oOrder->info['total']);
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_ORDER_TOTAL_TOTAL_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_ORDER_TOTAL_TOTAL_STATUS', 'MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_ORDER_TOTAL_TOTAL_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER', '7', '6', '2', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}

View File

@ -0,0 +1,159 @@
<?php
/* ----------------------------------------------------------------------
$Id: ot_xmembers.php,v 1.1 2007/06/07 17:30:51 r23 Exp $
MyOOS [Shopsystem]
https://www.oos-shop.de
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
----------------------------------------------------------------------
Based on:
File: ot_xmembers.php,v 1.1 2003/01/08 10:53:04 elarifr
ot_lev_members.php,v 1.0 2002/04/08 01:13:43 hpdl
----------------------------------------------------------------------
Customers_status v3.x / Catalog part
Copyright elari@free.fr
Contribution based on:
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 - 2003 osCommerce
----------------------------------------------------------------------
Released under the GNU General Public License
---------------------------------------------------------------------- */
class ot_xmembers {
var $title, $output, $enabled = FALSE;
public function __construct() {
global $aLang, $aUser;
$this->code = 'ot_xmembers';
$this->title = $aLang['module_xmembers_title'];
$this->description = $aLang['module_xmembers_description'];
$this->enabled = (defined('MODULE_XMEMBERS_STATUS') && (MODULE_XMEMBERS_STATUS == 'true') ? true : false);
$this->sort_order = (defined('MODULE_XMEMBERS_SORT_ORDER') ? MODULE_XMEMBERS_SORT_ORDER : null);
$this->include_shipping = (defined('MODULE_XMEMBERS_INC_SHIPPING') ? MODULE_XMEMBERS_INC_SHIPPING : null);
$this->include_tax = (defined('MODULE_XMEMBERS_INC_TAX') ? MODULE_XMEMBERS_INC_TAX : null);
$this->percentage = $aUser['ot_discount'];
$this->minimum = $aUser['ot_minimum'];
$this->calculate_tax = (defined('MODULE_XMEMBERS_CALC_TAX') ? MODULE_XMEMBERS_CALC_TAX : null);
$this->output = array();
}
function process() {
global $oOrder, $aUser, $oCurrencies;
$od_amount = $this->calculate_credit($this->get_order_total());
if ($od_amount>0) {
$this->deduction = $od_amount;
$this->output[] = array('title' => '<span class="otDiscount">- ' . $this->title . ' ('. number_format($aUser['ot_discount'], 2) .'%):</span>',
'text' => '<strong><span class="otDiscount">' . $oCurrencies->format($od_amount) . '</span></strong>',
'value' => $od_amount);
$oOrder->info['total'] = $oOrder->info['total'] - $od_amount;
}
}
function calculate_credit($amount) {
global $oOrder, $aUser;
$od_amount=0;
$od_pc = $this->percentage;
if ($amount > $this->minimum) {
if ($aUser['ot_discount_flag'] == '1') { // Calculate tax reduction if necessary
if ($this->calculate_tax == 'true') { // Calculate main tax reduction
$tod_amount = round($oOrder->info['tax']*10)/10*$od_pc/100;
$oOrder->info['tax'] = $oOrder->info['tax'] - $tod_amount; // Calculate tax group deductions
reset($oOrder->info['tax_groups']);
foreach($oOrder->info['tax_groups'] as $key => $value) {
$god_amount = round($value*10)/10*$od_pc/100;
$oOrder->info['tax_groups'][$key] = $oOrder->info['tax_groups'][$key] - $god_amount;
}
}
$od_amount = round($amount*10)/10*$od_pc/100;
$od_amount = $od_amount + $tod_amount;
}
}
return $od_amount;
}
function get_order_total() {
global $oOrder;
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$order_total = $oOrder->info['total'];
// Check if gift voucher is in cart and adjust total
$products = $_SESSION['cart']->get_products();
for ($i=0; $i<count($products); $i++) {
$t_prid = oos_get_product_id($products[$i]['id']);
$productstable = $oostable['products'];
$query = "SELECT products_price, products_tax_class_id, products_model
FROM $productstable
WHERE products_id = '" . intval($t_prid) . "'";
$gv_result = $dbconn->GetRow($query);
if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) {
$qty = $_SESSION['cart']->get_quantity($t_prid);
$products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']);
if ($this->include_tax == 'false') {
$gv_amount = $gv_result['products_price'] * $qty;
} else {
$gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'],$products_tax)) * $qty;
}
$order_total = $order_total - $gv_amount;
}
}
if ($this->include_tax == 'false') $order_total = $order_total-$oOrder->info['tax'];
if ($this->include_shipping == 'false') $order_total = $order_total-$oOrder->info['shipping_cost'];
return $order_total;
}
function check() {
if (!isset($this->_check)) {
$this->_check = defined('MODULE_XMEMBERS_STATUS');
}
return $this->_check;
}
function keys() {
return array('MODULE_XMEMBERS_STATUS', 'MODULE_XMEMBERS_SORT_ORDER', 'MODULE_XMEMBERS_INC_SHIPPING', 'MODULE_XMEMBERS_INC_TAX', 'MODULE_XMEMBERS_CALC_TAX');
}
function install() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function, date_added) values ('MODULE_XMEMBERS_STATUS', 'true', '6', '1','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, date_added) values ('MODULE_XMEMBERS_SORT_ORDER', '3', '6', '2', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_XMEMBERS_INC_SHIPPING', 'true', '6', '5', 'oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_XMEMBERS_INC_TAX', 'true', '6', '6','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
$dbconn->Execute("INSERT INTO $configurationtable (configuration_key, configuration_value, configuration_group_id, sort_order, set_function ,date_added) values ('MODULE_XMEMBERS_CALC_TAX', 'false', '6', '5','oos_cfg_select_option(array(\'true\', \'false\'), ', now())");
}
function remove() {
// Get database information
$dbconn =& oosDBGetConn();
$oostable =& oosDBGetTables();
$configurationtable = $oostable['configuration'];
$dbconn->Execute("DELETE FROM $configurationtable WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}