[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/modules/order_total/ -> ot_coupon.php (source)

   1  <?php
   2  /**

   3   * @package orderTotal

   4   * @copyright Copyright 2003-2006 Zen Cart Development Team

   5   * @copyright Portions Copyright 2003 osCommerce

   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   7   * @version $Id: ot_coupon.php 4562 2006-09-19 19:11:08Z wilt $

   8   */
   9  
  10    class ot_coupon {
  11      var $title, $output;
  12  
  13      function ot_coupon() {
  14  
  15        $this->code = 'ot_coupon';
  16        $this->header = MODULE_ORDER_TOTAL_COUPON_HEADER;
  17        $this->title = MODULE_ORDER_TOTAL_COUPON_TITLE;
  18        $this->description = MODULE_ORDER_TOTAL_COUPON_DESCRIPTION;
  19        $this->user_prompt = '';
  20        $this->sort_order = MODULE_ORDER_TOTAL_COUPON_SORT_ORDER;
  21        $this->include_shipping = MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING;
  22        $this->include_tax = MODULE_ORDER_TOTAL_COUPON_INC_TAX;
  23        $this->calculate_tax = MODULE_ORDER_TOTAL_COUPON_CALC_TAX;
  24        $this->tax_class  = MODULE_ORDER_TOTAL_COUPON_TAX_CLASS;
  25        $this->credit_class = true;
  26        $this->output = array();
  27  
  28      }
  29  
  30    function process() {
  31      global $order, $currencies, $db;
  32      $od_amount = $this->calculate_deductions($this->get_order_total());
  33      $this->deduction = $od_amount['total'];
  34      if ($od_amount['total'] > 0) {
  35        reset($order->info['tax_groups']);
  36        $tax = 0;
  37        while (list($key, $value) = each($order->info['tax_groups'])) {
  38          $tax_rate = zen_get_tax_rate_from_desc($key);
  39          if ($od_amount[$key]) {
  40            $order->info['tax_groups'][$key] -= $od_amount[$key];
  41            $order->info['total'] -=  $od_amount[$key];
  42            $tax += $od_amount[$key];
  43          }
  44        }
  45        if ($od_amount['type'] == 'S') $order->info['shipping_cost'] = 0;
  46        $sql = "select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_SESSION['cc_id'] . "'";
  47        $zq_coupon_code = $db->Execute($sql);
  48        $this->coupon_code = $zq_coupon_code->fields['coupon_code'];
  49        $order->info['total'] = $order->info['total'] - $od_amount['total'];
  50        if (DISPLAY_PRICE_WITH_TAX == 'true') {
  51          $od_amount['total'] += zen_calculate_tax($od_amount['total'], $tax);
  52        }
  53  
  54        $this->output[] = array('title' => $this->title . ': ' . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $this->coupon_code . '</a> :',
  55                                'text' => '-' . $currencies->format($od_amount['total']),
  56                                'value' => $od_amount['total']);
  57      }
  58    }
  59  
  60    function selection_test() {
  61      return false;
  62    }
  63  
  64    function clear_posts() {
  65      unset($_SESSION['cc_id']);
  66    }
  67  
  68    function pre_confirmation_check($order_total) {
  69      global $order;
  70      if ($this->include_shipping == 'false') $order_total -= $order->info['shipping_cost'];
  71      if ($this->include_tax == 'false') $order_total -= $order->info['tax'];
  72      $od_amount = $this->calculate_deductions($order_total);
  73      return $od_amount['total'] + $od_amount['tax'];
  74  //    return $od_amount['total'];

  75    }
  76  
  77    function use_credit_amount() {
  78      return false;
  79    }
  80  
  81    function credit_selection() {
  82      global $discount_coupon;
  83      global $db;
  84      // note the placement of the redeem code can be moved within the array on the instructions or the title

  85      $selection = array('id' => $this->code,
  86                         'module' => $this->title,
  87                         'redeem_instructions' => MODULE_ORDER_TOTAL_COUPON_REDEEM_INSTRUCTIONS . ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_REMOVE_INSTRUCTIONS : ''),
  88                         'fields' => array(array('title' => ($discount_coupon->fields['coupon_code'] != '' ? MODULE_ORDER_TOTAL_COUPON_TEXT_CURRENT_CODE . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $discount_coupon->fields['coupon_code'] . '</a><br />' : '') . MODULE_ORDER_TOTAL_COUPON_TEXT_ENTER_CODE,
  89                                                 'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-'.$this->code.'" onchange="submitFunction(0,0)"'),
  90                                                 'tag' => 'disc-'.$this->code
  91                         )));
  92      return $selection;
  93    }
  94  
  95    function collect_posts() {
  96      global $db, $currencies, $messageStack, $order;
  97  
  98  // remove discount coupon by request

  99      if (isset($_POST['dc_redeem_code']) && strtoupper($_POST['dc_redeem_code']) == 'REMOVE') {
 100        unset($_POST['dc_redeem_code']);
 101        unset($_SESSION['cc_id']);
 102        $messageStack->add_session('checkout_payment', TEXT_REMOVE_REDEEM_COUPON, 'caution');
 103      }
 104  
 105  // bof: Discount Coupon zoned always validate coupon for payment address changes

 106      if ($_SESSION['cc_id'] > 0) {
 107        $sql = "select coupon_id, coupon_amount, coupon_type, coupon_minimum_order, uses_per_coupon, uses_per_user,
 108                restrict_to_products, restrict_to_categories, coupon_zone_restriction, coupon_code
 109                from " . TABLE_COUPONS . "
 110                where coupon_id= :couponIDEntered
 111                and coupon_active='Y'";
 112        $sql = $db->bindVars($sql, ':couponIDEntered', $_SESSION['cc_id'], 'string');
 113  
 114        $coupon_result=$db->Execute($sql);
 115  
 116        $foundvalid = true;
 117  
 118        $check_flag = false;
 119        $check = $db->Execute("select zone_id, zone_country_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $coupon_result->fields['coupon_zone_restriction'] . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
 120  
 121        if ($coupon_result->fields['coupon_zone_restriction'] > 0) {
 122          while (!$check->EOF) {
 123            if ($check->fields['zone_id'] < 1) {
 124              $check_flag = true;
 125              break;
 126            } elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
 127              $check_flag = true;
 128              break;
 129            }
 130            $check->MoveNext();
 131          }
 132          $foundvalid = $check_flag;
 133        }
 134        // remove if fails address validation

 135        if (!$foundvalid) {
 136          unset($_POST['dc_redeem_code']);
 137          unset($_SESSION['cc_id']);
 138          $messageStack->add_session('checkout_payment', TEXT_REMOVE_REDEEM_COUPON_ZONE, 'caution');
 139          if (!$foundvalid) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL',true, false));
 140        }
 141      }
 142  // eof: Discount Coupon zoned always validate coupon for payment address changes

 143  
 144      if ($_POST['dc_redeem_code']) {
 145        $sql = "select coupon_id, coupon_amount, coupon_type, coupon_minimum_order, uses_per_coupon, uses_per_user,
 146                restrict_to_products, restrict_to_categories, coupon_zone_restriction
 147                from " . TABLE_COUPONS . "
 148                where coupon_code= :couponCodeEntered
 149                and coupon_active='Y'";
 150        $sql = $db->bindVars($sql, ':couponCodeEntered', $_POST['dc_redeem_code'], 'string');
 151  
 152        $coupon_result=$db->Execute($sql);
 153  
 154        if ($coupon_result->fields['coupon_type'] != 'G') {
 155  
 156          if ($coupon_result->RecordCount() < 1 ) {
 157            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_REDEEM_COUPON), 'SSL',true, false));
 158          }
 159          if ($this->get_order_total() < $coupon_result->fields['coupon_minimum_order']) {
 160            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon_result->fields['coupon_minimum_order']))), 'SSL',true, false));
 161          }
 162  
 163          // JTD - added missing code here to handle coupon product restrictions

 164          // look through the items in the cart to see if this coupon is valid for any item in the cart

 165          $products = $_SESSION['cart']->get_products();
 166          $foundvalid = true;
 167  
 168          if ($foundvalid == true) {
 169            $foundvalid = false;
 170            for ($i=0; $i<sizeof($products); $i++) {
 171              if (is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id'])) {
 172                $foundvalid = true;
 173                continue;
 174              }
 175            }
 176          }
 177  
 178          if (!$foundvalid) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_COUPON_PRODUCT), 'SSL',true, false));
 179           // JTD - end of additions of missing code to handle coupon product restrictions

 180  
 181          $date_query=$db->Execute("select coupon_start_date from " . TABLE_COUPONS . "
 182                                    where coupon_start_date <= now() and
 183                                    coupon_code='" . zen_db_prepare_input($_POST['dc_redeem_code']) . "'");
 184  
 185          if ($date_query->RecordCount() < 1 ) {
 186            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_STARTDATE_COUPON), 'SSL', true, false));
 187          }
 188  
 189          $date_query=$db->Execute("select coupon_expire_date from " . TABLE_COUPONS . "
 190                                    where coupon_expire_date >= now() and
 191                                    coupon_code='" . zen_db_prepare_input($_POST['dc_redeem_code']) . "'");
 192  
 193          if ($date_query->RecordCount() < 1 ) {
 194            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_FINISDATE_COUPON), 'SSL', true, false));
 195          }
 196  
 197          $coupon_count = $db->Execute("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . "
 198                                        where coupon_id = '" . (int)$coupon_result->fields['coupon_id']."'");
 199  
 200          $coupon_count_customer = $db->Execute("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . "
 201                                                 where coupon_id = '" . $coupon_result->fields['coupon_id']."' and
 202                                                 customer_id = '" . (int)$_SESSION['customer_id'] . "'");
 203  
 204          if ($coupon_count->RecordCount() >= $coupon_result->fields['uses_per_coupon'] && $coupon_result->fields['uses_per_coupon'] > 0) {
 205            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEXT_INVALID_USES_COUPON . $coupon_result->fields['uses_per_coupon'] . TIMES ), 'SSL', true, false));
 206          }
 207  
 208          if ($coupon_count_customer->RecordCount() >= $coupon_result->fields['uses_per_user'] && $coupon_result->fields['uses_per_user'] > 0) {
 209            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(sprintf(TEXT_INVALID_USES_USER_COUPON, $_POST['dc_redeem_code']) . $coupon_result->fields['uses_per_user'] . ($coupon_result->fields['uses_per_user'] == 1 ? TIME : TIMES) ), 'SSL', true,false));
 210          }
 211  
 212          if ($coupon_result->fields['coupon_type']=='S') {
 213            $coupon_amount = $order->info['shipping_cost'];
 214          } else {
 215            $coupon_amount = $currencies->format($coupon_result->fields['coupon_amount']) . ' ';
 216          }
 217          $_SESSION['cc_id'] = $coupon_result->fields['coupon_id'];
 218        }
 219  //      if ($_POST['submit_redeem_coupon_x'] && !$_POST['gv_redeem_code']) zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, 'credit_class_error_code=' . $this->code . '&credit_class_error=' . urlencode(TEST_NO_REDEEM_CODE), 'SSL', true, false));

 220        $messageStack->add_session('checkout', TEXT_VALID_COUPON,'success');
 221      }
 222    }
 223  
 224    function update_credit_account($i) {
 225      return false;
 226    }
 227  
 228    function apply_credit() {
 229      global $db, $insert_id;
 230      $cc_id = $_SESSION['cc_id'];
 231      if ($this->deduction !=0) {
 232        $db->Execute("insert into " . TABLE_COUPON_REDEEM_TRACK . "
 233                      (coupon_id, redeem_date, redeem_ip, customer_id, order_id)
 234                      values ('" . (int)$cc_id . "', now(), '" . $_SERVER['REMOTE_ADDR'] . "', '" . (int)$_SESSION['customer_id'] . "', '" . (int)$insert_id . "')");
 235      }
 236      $_SESSION['cc_id'] = "";
 237    }
 238  
 239    function calculate_deductions($order_total) {
 240      global $db, $order, $messageStack;
 241      $tax_address = zen_get_tax_locations();
 242      $od_amount = array();
 243      if ($_SESSION['cc_id']) {
 244        $coupon = $db->Execute("select * from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_SESSION['cc_id'] . "'");
 245        if (($coupon->RecordCount() > 0 && $order_total !=0) || ($coupon->RecordCount() > 0 && $coupon->fields['coupon_type']=='S') ) {
 246          if ($coupon->fields['coupon_minimum_order'] <= $order_total) {
 247            if ($coupon->fields['coupon_type']=='S') {
 248              $od_amount['total'] = $order->info['shipping_cost'];
 249              $od_amount['type'] = 'S';
 250            } else {
 251              if ($coupon->fields['coupon_type'] == 'P') {
 252                $od_amount['total'] = zen_round($order_total*($coupon->fields['coupon_amount']/100), 2);
 253              } else {
 254                $od_amount['total'] = $coupon->fields['coupon_amount'] * ($order_total>0);
 255              }
 256              if ($od_amount['total']>$order_total) $od_amount['total'] = $order_total;
 257              $products = $_SESSION['cart']->get_products();
 258              for ($i=0; $i<sizeof($products); $i++) {
 259                // speed up process and store value

 260                $is_valid_results = is_product_valid($products[$i]['id'], $_SESSION['cc_id']);
 261                if ($is_valid_results) {
 262                  if ($coupon->fields['coupon_type'] == 'P') {
 263                    switch ($this->calculate_tax) {
 264                      case 'Credit Note':
 265                        $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
 266                        $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
 267                        $od_amount[$tax_desc] = $od_amount['total'] / 100 * $tax_rate;
 268                        $od_amount['tax'] += $od_amount[$tax_desc];
 269                      break;
 270                      case 'Standard':
 271                        $ratio = $od_amount['total']/$this->get_order_total();
 272                        $products = $_SESSION['cart']->get_products();
 273                        for ($j=0; $j<sizeof($products); $j++) {
 274                          $t_prid = zen_get_prid($products[$j]['id']);
 275                          $cc_result = $db->Execute("select products_tax_class_id
 276                                                     from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
 277  
 278                          if ($is_valid_results) {
 279                            $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
 280                            $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
 281                            if ($tax_rate > 0) {
 282  //                            $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;

 283                              $od_amount[$tax_desc] += round(((($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2);
 284                              $od_amount['tax'] += $od_amount[$tax_desc];
 285                            }
 286                          }
 287                        }
 288                      break;
 289                      default:
 290                    }
 291                  }
 292                  if ($coupon->fields['coupon_type'] == 'F') {
 293                    switch ($this->calculate_tax) {
 294                      case 'Credit Note':
 295                        $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
 296                        $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
 297                        $od_amount[$tax_desc] = $od_amount['total'] / 100 * $tax_rate;
 298                        $od_amount['tax'] += $od_amount[$tax_desc];
 299                      break;
 300                      case 'Standard':
 301                        $ratio = $od_amount['total']/$this->get_order_total();
 302                        $products = $_SESSION['cart']->get_products();
 303                        for ($j=0; $j<sizeof($products); $j++) {
 304                          $t_prid = zen_get_prid($products[$j]['id']);
 305                          $cc_result = $db->Execute("select products_tax_class_id
 306                                                     from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
 307  
 308                          if ($is_valid_results) {
 309                            $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
 310                            $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
 311                            if ($tax_rate > 0) {
 312  //                            $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;

 313                              $od_amount[$tax_desc] += round(((($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate) + .5)/100 * $ratio, 2);
 314                              $od_amount['tax'] += $od_amount[$tax_desc];
 315                            }
 316                          }
 317                        }
 318                      break;
 319                      default:
 320                    }
 321                  }
 322                }
 323              }
 324            }
 325          }
 326        }
 327      }
 328      return $od_amount;
 329    }
 330  
 331    function get_order_total() {
 332      global  $order;
 333      $products = $_SESSION['cart']->get_products();
 334      $order_total = 0;
 335      for ($i=0; $i<sizeof($products); $i++) {
 336        if (is_product_valid($products[$i]['id'], $_SESSION['cc_id'])) {
 337          $order_total += $products[$i]['final_price'] * $products[$i]['quantity'];
 338            if ($this->include_tax == 'true') {
 339            $products_tax = zen_get_tax_rate($products[$i]['tax_class_id']);
 340            $order_total += (zen_calculate_tax($products[$i]['final_price'], $products_tax))   * $products[$i]['quantity'];
 341            }
 342        }
 343      }
 344      if ($this->include_shipping == 'true') $order_total += $order->info['shipping_cost'];
 345      return $order_total;
 346    }
 347  
 348    function get_product_price($product_id) {
 349      global $db, $order;
 350      $products_id = zen_get_prid($product_id);
 351   // products price

 352      $qty = $_SESSION['cart']->contents[$product_id]['qty'];
 353      $product = $db->Execute("select products_id, products_price, products_tax_class_id, products_weight
 354                               from " . TABLE_PRODUCTS . " where products_id='" . $products_id . "'");
 355  
 356      if ($product->RecordCount() > 0) {
 357        $prid = $product->fields['products_id'];
 358        $products_tax = zen_get_tax_rate($product->fields['products_tax_class_id']);
 359        $products_price = $product->fields['products_price'];
 360        $specials = $db->Execute("select specials_new_products_price
 361                                  from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
 362  
 363        if ($specials->RecordCount() > 0 ) {
 364          $products_price = $specials->fields['specials_new_products_price'];
 365        }
 366        if ($this->include_tax == 'true') {
 367          $total_price += ($products_price + zen_calculate_tax($products_price, $products_tax)) * $qty;
 368        } else {
 369          $total_price += $products_price * $qty;
 370        }
 371  
 372  // attributes price

 373        if (isset($_SESSION['cart']->contents[$product_id]['attributes'])) {
 374          reset($_SESSION['cart']->contents[$product_id]['attributes']);
 375          while (list($option, $value) = each($_SESSION['cart']->contents[$product_id]['attributes'])) {
 376            $attribute_price = $db->Execute("select options_values_price, price_prefix
 377                                             from " . TABLE_PRODUCTS_ATTRIBUTES . "
 378                                             where products_id = '" . (int)$prid . "'
 379                                             and options_id = '" . (int)$option . "'
 380                                             and options_values_id = '" . (int)$value . "'");
 381  
 382            if ($attribute_price->fields['price_prefix'] == '-') {
 383              if ($this->include_tax == 'true') {
 384                $total_price -= $qty * ($attribute_price->fields['options_values_price'] + zen_calculate_tax($attribute_price->fields['options_values_price'], $products_tax));
 385              } else {
 386                $total_price -= $qty * ($attribute_price->fields['options_values_price']);
 387              }
 388            } else {
 389              if ($this->include_tax == 'true') {
 390                $total_price += $qty * ($attribute_price->fields['options_values_price'] + zen_calculate_tax($attribute_price->fields['options_values_price'], $products_tax));
 391              } else {
 392                $total_price += $qty * ($attribute_price->fields['options_values_price']);
 393              }
 394            }
 395          }
 396        }
 397      }
 398      return $total_price;
 399    }
 400  
 401      function check() {
 402        global $db;
 403        if (!isset($this->check)) {
 404          $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COUPON_STATUS'");
 405          $this->check = $check_query->RecordCount();
 406        }
 407  
 408        return $this->check;
 409      }
 410  
 411      function keys() {
 412        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');
 413      }
 414  
 415      function install() {
 416        global $db;
 417        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('This module is installed', 'MODULE_ORDER_TOTAL_COUPON_STATUS', 'true', '', '6', '1','zen_cfg_select_option(array(\'true\'), ', now())");
 418        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_COUPON_SORT_ORDER', '280', 'Sort order of display.', '6', '2', now())");
 419        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_ORDER_TOTAL_COUPON_INC_SHIPPING', 'true', 'Include Shipping in calculation', '6', '5', 'zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
 420        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_ORDER_TOTAL_COUPON_INC_TAX', 'false', 'Include Tax in calculation.', '6', '6','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
 421        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Re-calculate Tax', 'MODULE_ORDER_TOTAL_COUPON_CALC_TAX', 'Standard', 'Re-Calculate Tax', '6', '7','zen_cfg_select_option(array(\'None\', \'Standard\', \'Credit Note\'), ', now())");
 422        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_COUPON_TAX_CLASS', '0', 'Use the following tax class when treating Discount Coupon as Credit Note.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
 423      }
 424  
 425      function remove() {
 426        global $db;
 427        $keys = '';
 428        $keys_array = $this->keys();
 429        for ($i=0; $i<sizeof($keys_array); $i++) {
 430          $keys .= "'" . $keys_array[$i] . "',";
 431        }
 432        $keys = substr($keys, 0, -1);
 433  
 434        $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
 435      }
 436    }
 437  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics