  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: item.php 1739 2007-12-20 00:52:16Z hpdl $ |
| |
| 3 | + | $Id: item.php 1841 2008-12-12 13:25:49Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
7 | 7 | | |
  |
8 | | - | Copyright (c) 2003 osCommerce |
| |
| 8 | + | Copyright (c) 2008 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | Released under the GNU General Public License |
| |
11 | 11 | | */ |
| |
|
|
 |
… |
|
46 | 46 | | |
| |
47 | 47 | | // class methods |
| |
48 | 48 | | function quote($method = '') { |
  |
49 | | - | global $order, $total_count; |
| |
| 49 | + | global $order; |
|
50 | 50 | | |
  |
| 51 | + | $number_of_items = $this->getNumberOfItems(); |
| |
| 52 | + | |
|
51 | 53 | | $this->quotes = array('id' => $this->code, |
| |
52 | 54 | | 'module' => MODULE_SHIPPING_ITEM_TEXT_TITLE, |
| |
53 | 55 | | 'methods' => array(array('id' => $this->code, |
| |
54 | 56 | | 'title' => MODULE_SHIPPING_ITEM_TEXT_WAY, |
  |
55 | | - | 'cost' => (MODULE_SHIPPING_ITEM_COST * $total_count) + MODULE_SHIPPING_ITEM_HANDLING))); |
| |
| 57 | + | 'cost' => (MODULE_SHIPPING_ITEM_COST * $number_of_items) + MODULE_SHIPPING_ITEM_HANDLING))); |
|
56 | 58 | | |
| |
57 | 59 | | if ($this->tax_class > 0) { |
| |
58 | 60 | | $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); |
| |
|
|
 |
… |
|
87 | 89 | | function keys() { |
| |
88 | 90 | | return array('MODULE_SHIPPING_ITEM_STATUS', 'MODULE_SHIPPING_ITEM_COST', 'MODULE_SHIPPING_ITEM_HANDLING', 'MODULE_SHIPPING_ITEM_TAX_CLASS', 'MODULE_SHIPPING_ITEM_ZONE', 'MODULE_SHIPPING_ITEM_SORT_ORDER'); |
| |
89 | 91 | | } |
  |
| 92 | + | |
| |
| 93 | + | function getNumberOfItems() { |
| |
| 94 | + | global $order, $total_count; |
| |
| 95 | + | |
| |
| 96 | + | $number_of_items = $total_count; |
| |
| 97 | + | |
| |
| 98 | + | if ($order->content_type == 'mixed') { |
| |
| 99 | + | $number_of_items = 0; |
| |
| 100 | + | |
| |
| 101 | + | for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { |
| |
| 102 | + | $number_of_items += $order->products[$i]['qty']; |
| |
| 103 | + | |
| |
| 104 | + | if (isset($order->products[$i]['attributes'])) { |
| |
| 105 | + | reset($order->products[$i]['attributes']); |
| |
| 106 | + | while (list($option, $value) = each($order->products[$i]['attributes'])) { |
| |
| 107 | + | $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$order->products[$i]['id'] . "' and pa.options_values_id = '" . (int)$value['value_id'] . "' and pa.products_attributes_id = pad.products_attributes_id"); |
| |
| 108 | + | $virtual_check = tep_db_fetch_array($virtual_check_query); |
| |
| 109 | + | |
| |
| 110 | + | if ($virtual_check['total'] > 0) { |
| |
| 111 | + | $number_of_items -= $order->products[$i]['qty']; |
| |
| 112 | + | } |
| |
| 113 | + | } |
| |
| 114 | + | } |
| |
| 115 | + | } |
| |
| 116 | + | } |
| |
| 117 | + | |
| |
| 118 | + | return $number_of_items; |
| |
| 119 | + | } |
  |
90 | 120 | | } |
| |
91 | 121 | | ?> |