📄 ot_gv.php
字号:
<?php
/* -----------------------------------------------------------------------------------------
$Id: ot_gv.php,v 1.3 2004/04/24 14:56:55 oldpa Exp $
TWE-Commerce - community made shopping
http://www.oldpa.com.tw
Copyright (c) 2003 TWE-Commerce
-----------------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce(ot_gv.php,v 1.37.3 2004/01/01); www.oscommerce.com
(c) 2003 xt-commerce www.xt-commerce.com
Released under the GNU General Public License
-----------------------------------------------------------------------------------------
Third Party contributions:
Credit Class/Gift Vouchers/Discount Coupons (Version 5.10)
http://www.oscommerce.com/community/contributions,282
Copyright (c) Strider | Strider@oscworks.com
Copyright (c Nick Stanko of UkiDev.com, nick@ukidev.com
Copyright (c) Andre ambidex@gmx.net
Copyright (c) 2001,2002 Ian C Wilson http://www.phesis.org
Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
class ot_gv {
var $title, $output;
function ot_gv() {
$this->code = 'ot_gv';
$this->title = MODULE_ORDER_TOTAL_GV_TITLE;
$this->header = MODULE_ORDER_TOTAL_GV_HEADER;
$this->description = MODULE_ORDER_TOTAL_GV_DESCRIPTION;
$this->user_prompt = MODULE_ORDER_TOTAL_GV_USER_PROMPT;
$this->enabled = MODULE_ORDER_TOTAL_GV_STATUS;
$this->sort_order = MODULE_ORDER_TOTAL_GV_SORT_ORDER;
$this->include_shipping = MODULE_ORDER_TOTAL_GV_INC_SHIPPING;
$this->include_tax = MODULE_ORDER_TOTAL_GV_INC_TAX;
$this->calculate_tax = MODULE_ORDER_TOTAL_GV_CALC_TAX;
$this->credit_tax = MODULE_ORDER_TOTAL_GV_CREDIT_TAX;
$this->tax_class = MODULE_ORDER_TOTAL_GV_TAX_CLASS;
$this->show_redeem_box = MODULE_ORDER_TOTAL_GV_REDEEM_BOX;
$this->credit_class = true;
$this->checkbox = $this->user_prompt . '<input type="checkbox" onClick="submitFunction()" name="' . 'c' . $this->code . '">';
$this->output = array();
}
function process() {
global $order, $currencies;
// if ($_SESSION['cot_gv']) { // old code Strider
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;
// if (($this->calculate_tax == "Credit Note") && (DISPLAY_PRICE_WITH_TAX != 'true')) {
// $od_amount -= $tod_amount;
// $order->info['total'] -= $tod_amount;
// }
$order->info['total'] = $order->info['total'] - $od_amount;
if ($od_amount > 0) {
$this->output[] = array('title' => $this->title . ':',
'text' => '<b><font color="ff0000">-' .twe_format_price($od_amount, $price_special=1, $calculate_currencies=false) . '</font></b>',
'value' => twe_format_price($od_amount, $price_special=0, $calculate_currencies=false));
}
}
}
function selection_test() {
if ($this->user_has_gv_account($_SESSION['customer_id'])) {
return true;
} else {
return false;
}
}
function pre_confirmation_check($order_total) {
global $order;
// if ($_SESSION['cot_gv']) { // old code Strider
$od_amount = 0; // set the default amount we will send back
if (isset($_SESSION['cot_gv']) && $_SESSION['cot_gv'] == true) {
// pre confirmation check doesn't do a true order process. It just attempts to see if
// there is enough to handle the order. But depending on settings it will not be shown
// all of the order so this is why we do this runaround jane. What do we know so far.
// nothing. Since we need to know if we process the full amount we need to call get order total
// if there has been something before us then
if ($this->include_tax == 'false') {
$order_total = $order_total - $order->info['tax'];
}
if ($this->include_shipping == 'false') {
$order_total = $order_total - $order->info['shipping_cost'];
}
$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)+$tod_amount;
}
}
return $od_amount;
}
// original code
/*function pre_confirmation_check($order_total) {
if ($SESSION['cot_gv']) {
$gv_payment_amount = $this->calculate_credit($order_total);
}
return $gv_payment_amount;
} */
function use_credit_amount() {
// $_SESSION['cot_gv'] = false; // old code - Strider
$_SESSION['cot_gv'] = false;
if ($this->selection_test()) {
$output_string .= ' <td nowrap align="right" class="main">';
$output_string .= '<b>' . $this->checkbox . '</b>' . '</td>' . "\n";
}
return $output_string;
}
function update_credit_account($i) {
global $order, $insert_id, $REMOTE_ADDR;
if (ereg('^GIFT', addslashes($order->products[$i]['model']))) {
$gv_order_amount = ($order->products[$i]['final_price']);
if ($this->credit_tax=='true') $gv_order_amount = $gv_order_amount * (100 + $order->products[$i]['tax']) / 100;
// $gv_order_amount += 0.001;
$gv_order_amount = $gv_order_amount * 100 / 100;
if (MODULE_ORDER_TOTAL_GV_QUEUE == 'false') {
// GV_QUEUE is false so release amount to account immediately
$gv_query=twe_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $_SESSION['customer_id'] . "'");
$customer_gv = false;
$total_gv_amount = 0;
if ($gv_result = twe_db_fetch_array($gv_query)) {
$total_gv_amount = $gv_result['amount'];
$customer_gv = true;
}
$total_gv_amount = $total_gv_amount + $gv_order_amount;
if ($customer_gv) {
$gv_update=twe_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $total_gv_amount . "' where customer_id = '" . $_SESSION['customer_id'] . "'");
} else {
$gv_insert=twe_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $_SESSION['customer_id'] . "', '" . $total_gv_amount . "')");
}
} else {
// GV_QUEUE is true - so queue the gv for release by store owner
$gv_insert=twe_db_query("insert into " . TABLE_COUPON_GV_QUEUE . " (customer_id, order_id, amount, date_created, ipaddr) values ('" . $_SESSION['customer_id'] . "', '" . $insert_id . "', '" . $gv_order_amount . "', NOW(), '" . $REMOTE_ADDR . "')");
}
}
}
function credit_selection() {
global $currencies;
$selection_string = '';
$gv_query = twe_db_query("select coupon_id from " . TABLE_COUPONS . " where coupon_type = 'G' and coupon_active='Y'");
/*
if (twe_db_num_rows($gv_query)) {
$selection_string .= '<tr>' . "\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -