[ 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/ -> products_quantity_discounts.php (source)

   1  <?php
   2  /**

   3   * products_quantity_discounts module

   4   *

   5   * @package modules

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

   7   * @copyright Portions Copyright 2003 osCommerce

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

   9   * @version $Id: products_quantity_discounts.php 4135 2006-08-14 04:25:02Z drbyte $

  10   */
  11  if (!defined('IS_ADMIN_FLAG')) {
  12    die('Illegal Access');
  13  }
  14  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
  15  
  16  // if customer authorization is on do not show discounts

  17  
  18  $zc_hidden_discounts_on = false;
  19  $zc_hidden_discounts_text = '';
  20  switch (true) {
  21    case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
  22    // customer must be logged in to browse

  23    $zc_hidden_discounts_on = true;
  24    $zc_hidden_discounts_text = 'MUST LOGIN';
  25    break;
  26    case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
  27    // customer may browse but no prices

  28    $zc_hidden_discounts_on = true;
  29    $zc_hidden_discounts_text = TEXT_LOGIN_FOR_PRICE_PRICE;
  30    break;
  31    case (CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != ''):
  32    // customer may browse but no prices

  33    $zc_hidden_discounts_on = true;
  34    $zc_hidden_discounts_text = TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
  35    break;
  36    case (CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and $_SESSION['customer_id'] == ''):
  37    // customer must be logged in to browse

  38    $zc_hidden_discounts_on = true;
  39    $zc_hidden_discounts_text = TEXT_AUTHORIZATION_PENDING_PRICE;
  40    break;
  41    case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customers_authorization'] > '0'):
  42    // customer must be logged in to browse

  43    $zc_hidden_discounts_on = true;
  44    $zc_hidden_discounts_text = TEXT_AUTHORIZATION_PENDING_PRICE;
  45    break;
  46    default:
  47    // proceed normally

  48    break;
  49  }
  50  // create products discount output table

  51  
  52  // find out the minimum quantity for this product

  53  $products_min_query = $db->Execute("select products_quantity_order_min from " . TABLE_PRODUCTS . " where products_id='" . (int)$products_id_current . "'");
  54  $products_quantity_order_min = $products_min_query->fields['products_quantity_order_min'];
  55  
  56  // retrieve the list of discount levels for this product

  57  $products_discounts_query = $db->Execute("select * from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id='" . (int)$products_id_current . "' and discount_qty !=0 " . " order by discount_qty");
  58  
  59  
  60  $discount_col_cnt = DISCOUNT_QUANTITY_PRICES_COLUMN;
  61  
  62  $display_price = zen_get_products_base_price($products_id_current);
  63  $display_specials_price = zen_get_products_special_price($products_id_current, true);
  64  
  65  // set first price value

  66  if ($display_specials_price == false) {
  67    $show_price = $display_price;
  68  } else {
  69    $show_price = $display_specials_price;
  70  }
  71  
  72  switch (true) {
  73    case ($products_discounts_query->fields['discount_qty'] <= 2):
  74    $show_qty = '1';
  75    break;
  76    case ($products_quantity_order_min == ($products_discounts_query->fields['discount_qty']-1) || $products_quantity_order_min == ($products_discounts_query->fields['discount_qty'])):
  77    $show_qty = $products_quantity_order_min;
  78    break;
  79    default:
  80    $show_qty = $products_quantity_order_min . '-' . number_format($products_discounts_query->fields['discount_qty']-1);
  81    break;
  82  }
  83  //$discounted_price = $products_discounts_query->fields['discount_price'];

  84  // $currencies->display_price($discounted_price, zen_get_tax_rate(1), 1)

  85  
  86  $display_price = zen_get_products_base_price($products_id_current);
  87  $display_specials_price = zen_get_products_special_price($products_id_current, true);
  88  $disc_cnt = 1;
  89  $quantityDiscounts = array();
  90  $columnCount = 0;
  91  while (!$products_discounts_query->EOF) {
  92    $disc_cnt++;
  93    switch ($products_discount_type) {
  94      // none

  95      case '0':
  96        $quantityDiscounts[$columnCount]['discounted_price'] = 0;
  97      break;
  98      // percentage discount

  99      case '1':
 100        if ($products_discount_type_from == '0') {
 101          $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - ($display_price * ($products_discounts_query->fields['discount_price']/100));
 102        } else {
 103          if (!$display_specials_price) {
 104            $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - ($display_price * ($products_discounts_query->fields['discount_price']/100));
 105          } else {
 106            $quantityDiscounts[$columnCount]['discounted_price'] = $display_specials_price - ($display_specials_price * ($products_discounts_query->fields['discount_price']/100));
 107          }
 108        }
 109      break;
 110      // actual price

 111      case '2':
 112        if ($products_discount_type_from == '0') {
 113          $quantityDiscounts[$columnCount]['discounted_price'] = $products_discounts_query->fields['discount_price'];
 114        } else {
 115          $quantityDiscounts[$columnCount]['discounted_price'] = $products_discounts_query->fields['discount_price'];
 116        }
 117      break;
 118      // amount offprice

 119      case '3':
 120        if ($products_discount_type_from == '0') {
 121          $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - $products_discounts_query->fields['discount_price'];
 122        } else {
 123          if (!$display_specials_price) {
 124            $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - $products_discounts_query->fields['discount_price'];
 125          } else {
 126            $quantityDiscounts[$columnCount]['discounted_price'] = $display_specials_price - $products_discounts_query->fields['discount_price'];
 127          }
 128        }
 129      break;
 130    }
 131  
 132    $quantityDiscounts[$columnCount]['show_qty'] = number_format($products_discounts_query->fields['discount_qty']);
 133    $products_discounts_query->MoveNext();
 134    if ($products_discounts_query->EOF) {
 135      $quantityDiscounts[$columnCount]['show_qty'] .= '+';
 136    } else {
 137      if (($products_discounts_query->fields['discount_qty']-1) != $show_qty) {
 138        if ($quantityDiscounts[$columnCount]['show_qty'] < $products_discounts_query->fields['discount_qty']-1) {
 139          $quantityDiscounts[$columnCount]['show_qty'] .= '-' . number_format($products_discounts_query->fields['discount_qty']-1);
 140        }
 141      }
 142    }
 143    $disc_cnt=0;
 144    $columnCount++;
 145  }
 146  ?>


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