[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_shop/inc/ -> cart.items.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  $x = 0;
  31  $cart_items = array();
  32  $total        = array();
  33  $subtotal    = array('net' => 0, 'vat' => 0, 'gross' => 0, 'weight' => 0);
  34  
  35  
  36  foreach($cart_data as $item_key => $row) {
  37      
  38      $prod_id = $row['shopprod_id'];
  39      
  40      $total[$prod_id]['quantity']    = $_SESSION['shopping_cart']['products'][$prod_id];
  41      $total[$prod_id]['vat']            = $row['shopprod_vat'];
  42      if($row['shopprod_netgross'] == 1) {
  43          // price given is GROSS price, including VAT
  44          $total[$prod_id]['net']        = $row['shopprod_price'] / (1 + $row['shopprod_vat'] / 100);
  45          $total[$prod_id]['gross']    = $row['shopprod_price'];
  46      } else {
  47          // price given is NET price, excluding VAT
  48          $total[$prod_id]['net']        = $row['shopprod_price'];
  49          $total[$prod_id]['gross']    = $row['shopprod_price'] * (1 + $row['shopprod_vat'] / 100);
  50      }
  51      
  52      $subtotal['net']    += $total[$prod_id]['quantity'] * $total[$prod_id]['net'];
  53      $subtotal['vat']    += $total[$prod_id]['quantity'] * ($total[$prod_id]['gross'] - $total[$prod_id]['net']);
  54      $subtotal['gross']    += $total[$prod_id]['quantity'] * $total[$prod_id]['gross'];
  55      $subtotal['weight']    += $total[$prod_id]['quantity'] * $row['shopprod_weight'];
  56  
  57      $_price['vat']        = number_format($total[$prod_id]['vat'],   $_tmpl['config']['vat_decimals'],   $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']);
  58      $_price['net']        = number_format($total[$prod_id]['net'],   $_tmpl['config']['price_decimals'], $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']);
  59      $_price['gross']    = number_format($total[$prod_id]['gross'], $_tmpl['config']['price_decimals'], $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']);
  60      $_price['weight']    = $row['shopprod_weight'] > 0 ? number_format($row['shopprod_weight'], $_tmpl['config']['weight_decimals'], $_tmpl['config']['dec_point'], $_tmpl['config']['thousands_sep']) : '';
  61  
  62      switch($cart_mode) {
  63  
  64          case 'cart':    $cart_items[$x]  = $_tmpl['cart_entry'];
  65                          break;
  66  
  67          case 'terms':    $cart_items[$x]  = $_tmpl['term_entry'];
  68                          break;
  69  
  70          case 'mail1':    $cart_items[$x]  = trim( $_tmpl['mail_item'] );
  71                          if(empty($cart_items[$x])) {
  72                              $cart_items[$x]  = 'Qty:   {COUNT}' . LF;
  73                              $cart_items[$x] .= 'Ord#:  {ORDER_NUM}' . LF;
  74                              $cart_items[$x] .= 'Item:  {PRODUCT_TITLE}' . LF;
  75                              $cart_items[$x] .= 'Net:   {PRODUCT_NET_PRICE} {CURRENCY_SYMBOL}' . LF;
  76                              $cart_items[$x] .= 'VAT:   {PRODUCT_VAT} %' . LF;
  77                              $cart_items[$x] .= 'Gross: {PRODUCT_GROSS_PRICE} {CURRENCY_SYMBOL}';
  78                          }
  79                          break;
  80      }
  81      
  82      $cart_items[$x] = str_replace('{PRODUCT_DETAIL_LINK}', $_tmpl['config']['shop_url'].'&amp;shop_detail=' . $prod_id, $cart_items[$x]);
  83      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_TITLE', html_specialchars($row['shopprod_name1']));
  84      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_SHORT', $row['shopprod_description0']);
  85      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_NET_PRICE', $_price['net']);
  86      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_GROSS_PRICE', $_price['gross']);
  87      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_WEIGHT', $_price['weight']);
  88      $cart_items[$x] = render_cnt_template($cart_items[$x], 'PRODUCT_VAT', $_price['vat']);
  89      $cart_items[$x] = render_cnt_template($cart_items[$x], 'ORDER_NUM', html_specialchars($row['shopprod_ordernumber']));
  90      $cart_items[$x] = render_cnt_template($cart_items[$x], 'MODEL', html_specialchars($row['shopprod_model']));
  91      
  92      switch($cart_mode) {
  93          case 'cart':
  94              $cart_items[$x] = str_replace('{COUNT}', '<input type="text" name="shop_prod_amount['.$prod_id.']" value="' . $total[$prod_id]['quantity'] . '" size="3" />', $cart_items[$x]);
  95              break;
  96          default:
  97              $cart_items[$x] = str_replace('{COUNT}', $total[$prod_id]['quantity'], $cart_items[$x]);
  98      }
  99  
 100      
 101      $x++;
 102  
 103  }
 104  
 105  // set shipping fees
 106  $subtotal['shipping_net']    = 0;
 107  $subtotal['shipping_vat']    = 0;
 108  $subtotal['shipping_gross'] = 0;
 109  $subtotal['shipping_calc']    = false;
 110  
 111  foreach( _getConfig( 'shop_pref_shipping', '_shopPref' ) as $item_key => $row ) {
 112      
 113      // do nothing as long shipping fee = 0
 114      if( $row['net'] == 0 ) {
 115          continue;
 116      }
 117      
 118      // lower weight and current shipping fee lower then this
 119      if( $subtotal['weight'] <= $row['weight'] ) { /* && $subtotal['shipping_net'] <= $row['net'] ) {
 120  
 121          $subtotal['shipping_calc'] = true;
 122  
 123      } elseif( $subtotal['weight'] > $row['weight'] && $subtotal['shipping_net'] < $row['net'] ) { */
 124      
 125          $subtotal['shipping_calc'] = true;
 126          
 127      }
 128      
 129      if( $subtotal['shipping_calc'] ) {
 130      
 131          $subtotal['shipping_net']    = $row['net'];
 132          $subtotal['shipping_gross']    = $subtotal['shipping_net'] * ( 1 + ($row['vat'] / 100) );
 133          $subtotal['shipping_vat']    = $subtotal['shipping_gross'] - $subtotal['shipping_net'];
 134          
 135          break;
 136      }
 137  
 138  }
 139  
 140  
 141  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7