⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ot_coupon.php

📁 美国cre loaded 6.2 b2b网站系统升级补丁
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/*  $Id: ot_coupon.php,v 1.4 2004/03/09 17:56:06 ccwjr Exp $    osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2002 osCommerce  Released under the GNU General Public License*/class ot_coupon {var $title, $output;function ot_coupon() {  $this->code = 'ot_coupon';  $this->header = MODULE_ORDER_TOTAL_COUPON_HEADER;  $this->title = MODULE_ORDER_TOTAL_COUPON_TITLE;  $this->description = MODULE_ORDER_TOTAL_COUPON_DESCRIPTION;  $this->user_prompt = '';  $this->enabled = MODULE_ORDER_TOTAL_COUPON_STATUS;  $this->sort_order = MODULE_ORDER_TOTAL_COUPON_SORT_ORDER;  $this->include_shipping = MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING;  $this->include_tax = MODULE_ORDER_TOTAL_COUPON_INC_TAX;  $this->calculate_tax = MODULE_ORDER_TOTAL_COUPON_CALC_TAX;  $this->tax_class = MODULE_ORDER_TOTAL_COUPON_TAX_CLASS;  $this->credit_class = true;  $this->output = array();}function process() {global $PHP_SELF, $order, $currencies, $cc_id;  $order_total=$this->get_order_total();  $od_amount = $this->calculate_credit($order_total);  $tod_amount = 0.0; //Fred  $this->deduction = $od_amount;  if ($this->calculate_tax != 'None') { //Fred - changed from 'none' to 'None'!    $tod_amount = $this->calculate_tax_deduction($order_total, $this->deduction, $this->calculate_tax);  }  if ($od_amount > 0) {    $order->info['total'] = $order->info['total'] - $od_amount;    $this->output[] = array('title' => $this->title . ':' . $this->coupon_code .':','text' => '<b>-' . $currencies->format($od_amount) . '</b>', 'value' => $od_amount); //Fred added hyphen  }}function selection_test() {  return false;}function pre_confirmation_check($order_total) {global $customer_id;  return $this->calculate_credit($order_total);}function use_credit_amount() {  return $output_string;}/*function credit_selection() {global $customer_id, $currencies, $language;  $selection_string = '';  $selection_string .= '<tr>' . "\n";  $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>';  $selection_string .= ' <td class="main">' . "\n";  $image_submit = '<input type="image" name="submit_redeem" onClick="submitFunction()" src="' . DIR_WS_TEMPLATES . TEMPLATE_NAME . '/images/buttons/' . $language . '/button_redeem.gif" border="0" alt="' . IMAGE_REDEEM_VOUCHER . '" title = "' . IMAGE_REDEEM_VOUCHER . '">';  $selection_string .= TEXT_ENTER_COUPON_CODE . tep_draw_input_field('gv_redeem_code') . '</td>';  $selection_string .= ' <td align="right">' . $image_submit . '</td>';  $selection_string .= ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>';  $selection_string .= '</tr>' . "\n";  return $selection_string;}*/function credit_selection() {global $customer_id, $currencies, $language;  $selection_string2 = '';  $selection_string2 .= '<tr>' . "\n";  $selection_string2 .= '<td class="main">' . "\n";  $selection_string2 .= TEXT_ENTER_GV_CODE . tep_draw_input_field('gv_redeem_code') . ' and click ';  $image_submit2 = tep_template_image_submit('button_redeem.gif', IMAGE_REDEEM_VOUCHER, 'onClick="submitFunction()"');  $selection_string2 .= ' </td><td align="right">' . $image_submit2 . '</td>';  $selection_string2 .= '</tr>' . "\n";        return $selection_string2;}function collect_posts() {global $HTTP_POST_VARS, $customer_id, $currencies, $cc_id;  if ($HTTP_POST_VARS['gv_redeem_code']) {// get some info from the coupon table  $coupon_query=tep_db_query("select coupon_id, coupon_amount, coupon_type, coupon_minimum_order,uses_per_coupon, uses_per_user, restrict_to_products,restrict_to_categories from " . TABLE_COUPONS . " where coupon_code='".tep_db_input($HTTP_POST_VARS['gv_redeem_code'])."' and coupon_active='Y'");  $coupon_result=tep_db_fetch_array($coupon_query);  if ($coupon_result['coupon_type'] != 'G') {    if (tep_db_num_rows($coupon_query)==0) {      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL'));    }    $date_query=tep_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='".tep_db_input($HTTP_POST_VARS['gv_redeem_code'])."'");    if (tep_db_num_rows($date_query)==0) {      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL'));  }    $date_query=tep_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='".tep_db_input($HTTP_POST_VARS['gv_redeem_code'])."'");    if (tep_db_num_rows($date_query)==0) {        tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL'));    }    $coupon_count = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."'");    $coupon_count_customer = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id']."' and customer_id = '" . $customer_id . "'");    if (tep_db_num_rows($coupon_count)>=$coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) {      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES ), 'SSL'));  }    if (tep_db_num_rows($coupon_count_customer)>=$coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) {      tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES ), 'SSL'));  }/*    if ($coupon_result['coupon_type']=='S') {      $coupon_amount = $order->info['shipping_cost'];    } else {      $coupon_amount = $currencies->format($coupon_result['coupon_amount']) . ' ';    }    if ($coupon_result['coupon_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'];    if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id'); //Fred - this was commented out before    $cc_id = $coupon_result['coupon_id']; //Fred ADDED, set the global and session variable                tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_REDEEMED_AMOUNT), 'SSL')); // Added in v5.13a by Rigadin*/                global $order,$ot_coupon,$currency,$cc_id;                if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id');                $cc_id = $coupon_result['coupon_id'];                $coupon_amount= tep_round($ot_coupon->pre_confirmation_check($order->info['subtotal']), $currencies->currencies[$currency]['decimal_places']); // $cc_id/* you will need to uncomment this if your tax order total module is AFTER shipping eg you have all of your tax, including tax from shipping module, in your tax total.                if ($coupon_result['coupon_type']=='S')  {                        //if not zero rated add vat to shipping                        $coupon_amount = tep_add_tax($coupon_amount, '17.5');                }*/                $coupon_amount_out = $currencies->format($coupon_amount) . ' ';                if ($coupon_result['coupon_minimum_order']>0) $coupon_amount_out .= 'on orders greater than ' . $currencies->format($coupon_result['coupon_minimum_order']);                if ( strlen($cc_id) > 0 && $coupon_amount == 0 ) {                        $err_msg = ERROR_REDEEMED_AMOUNT_ZERO;                } else {                        $err_msg = ERROR_REDEEMED_AMOUNT.$coupon_amount_out;                }                tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode($err_msg), 'SSL'));//**si** 09-11-05 end                // $_SESSION['cc_id'] = $coupon_result['coupon_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead.          } // ENDIF valid coupon code        } // ENDIF code entered         // v5.13a If no code entered and coupon redeem button pressed, give an alarm        if ($HTTP_POST_VARS['submit_redeem_coupon_x']) tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL'));}function calculate_credit($amount) {  global $customer_id, $order, $cc_id;  //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead.  $od_amount = 0;  if (isset($cc_id) ) {    $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'");    if (tep_db_num_rows($coupon_query) !=0 ) {      $coupon_result = tep_db_fetch_array($coupon_query);      $this->coupon_code = $coupon_result['coupon_code'];      $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS ." where coupon_code = '". $coupon_result['coupon_code'] . "'");      $get_result = tep_db_fetch_array($coupon_get);      $c_deduct = $get_result['coupon_amount'];      if ($get_result['coupon_type']=='S') $c_deduct = $order->info['shipping_cost'];      //v5.14 id coupon total > 0      if ($get_result['coupon_type']=='S') $c_deduct = $order->info['shipping_cost'];      if ($get_result['coupon_type']=='S' && $get_result['coupon_amount'] > 0 ) $c_deduct = $order->info['shipping_cost'] + $get_result['coupon_amount'];      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 < sizeof($order->products); $i++) {            if ($get_result['restrict_to_products']) {              $pr_ids = split("[,]", $get_result['restrict_to_products']);              for ($ii = 0; $ii < count($pr_ids); $ii++) {                if ($pr_ids[$ii] == tep_get_prid($order->products[$i]['id'])) {                  if ($get_result['coupon_type'] == 'P') {                    /* Fixes to Gift Voucher module 5.03

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -