Quick Search:

View

Revision:

Diff

Diff from 383 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/includes/classes/order.php

Annotated File View

hpdl
1
1 <?php
2 /*
hpdl
20
3   $Id: order.php 383 2006-01-09 16:35:46Z hpdl $
hpdl
1
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
20
8   Copyright (c) 2005 osCommerce
hpdl
1
9
10   Released under the GNU General Public License
11 */
12
13   class order {
14     var $info, $totals, $products, $customer, $delivery, $content_type;
15
hpdl
368
16 /* Private variables */
17
18     var $_id;
19
20 /* Class constructor */
21
hpdl
1
22     function order($order_id = '') {
hpdl
368
23       if (is_numeric($order_id)) {
24         $this->_id = $order_id;
25       }
26
hpdl
1
27       $this->info = array();
28       $this->totals = array();
29       $this->products = array();
30       $this->customer = array();
31       $this->delivery = array();
32
33       if (tep_not_null($order_id)) {
34         $this->query($order_id);
35       } else {
36         $this->cart();
37       }
38     }
39
hpdl
368
40 /* Public methods */
41
42     function &getListing($limit = null, $page_keyword = 'page') {
hpdl
383
43       global $osC_Database, $osC_Customer, $osC_Language;
hpdl
368
44
45       $Qorders = $osC_Database->query('select o.orders_id, o.date_purchased, o.delivery_name, o.delivery_country, o.billing_name, o.billing_country, ot.text as order_total, s.orders_status_name from :table_orders o, :table_orders_total ot, :table_orders_status s where o.customers_id = :customers_id and o.orders_id = ot.orders_id and ot.class = "ot_total" and o.orders_status = s.orders_status_id and s.language_id = :language_id order by orders_id desc');
46       $Qorders->bindTable(':table_orders', TABLE_ORDERS);
47       $Qorders->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
48       $Qorders->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
49       $Qorders->bindInt(':customers_id', $osC_Customer->getID());
hpdl
383
50       $Qorders->bindInt(':language_id', $osC_Language->getID());
hpdl
368
51
52       if (is_numeric($limit)) {
53         $Qorders->setBatchLimit(isset($_GET[$page_keyword]) && is_numeric($_GET[$page_keyword]) ? $_GET[$page_keyword] : 1, $limit);
54       }
55
56       $Qorders->execute();
57
58       return $Qorders;
59     }
60
61     function &getStatusListing($id = null) {
hpdl
383
62       global $osC_Database, $osC_Language;
hpdl
368
63
64       if ( ($id === null) && isset($this) ) {
65         $id = $this->_id;
66       }
67
68       $Qstatus = $osC_Database->query('select os.orders_status_name, osh.date_added, osh.comments from :table_orders_status os, :table_orders_status_history osh where osh.orders_id = :orders_id and osh.orders_status_id = os.orders_status_id and os.language_id = :language_id order by osh.date_added');
69       $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
70       $Qstatus->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY);
71       $Qstatus->bindInt(':orders_id', $id);
hpdl
383
72       $Qstatus->bindInt(':language_id', $osC_Language->getID());
hpdl
368
73
74       return $Qstatus;
75     }
76
77     function getCustomerID($id = null) {
78       global $osC_Database;
79
80       if ( ($id === null) && isset($this) ) {
81         $id = $this->_id;
82       }
83
84       $Qcustomer = $osC_Database->query('select customers_id from :table_orders where orders_id = :orders_id');
85       $Qcustomer->bindTable(':table_orders', TABLE_ORDERS);
86       $Qcustomer->bindInt(':orders_id', $id);
87       $Qcustomer->execute();
88
89       return $Qcustomer->valueInt('customers_id');
90     }
91
92     function numberOfEntries() {
93       global $osC_Database, $osC_Customer;
94       static $total_entries;
95
96       if (is_numeric($total_entries) === false) {
97         if ($osC_Customer->isLoggedOn()) {
98           $Qorders = $osC_Database->query('select count(*) as total from :table_orders where customers_id = :customers_id');
99           $Qorders->bindTable(':table_orders', TABLE_ORDERS);
100           $Qorders->bindInt(':customers_id', $osC_Customer->getID());
101           $Qorders->execute();
102
103           $total_entries = $Qorders->valueInt('total');
104         } else {
105           $total_entries = 0;
106         }
107       }
108
109       return $total_entries;
110     }
111
112     function numberOfProducts($id = null) {
113       global $osC_Database;
114
115       if ( ($id === null) && isset($this) ) {
116         $id = $this->_id;
117       }
118
119       $Qproducts = $osC_Database->query('select count(*) as total from :table_orders_products where orders_id = :orders_id');
120       $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
121       $Qproducts->bindInt(':orders_id', $id);
122       $Qproducts->execute();
123
124       return $Qproducts->valueInt('total');
125     }
126
127
128
hpdl
1
129     function query($order_id) {
hpdl
383
130       global $osC_Database, $osC_Language;
hpdl
1
131
hpdl
20
132       $Qorder = $osC_Database->query('select customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from :table_orders where orders_id = :orders_id');
133       $Qorder->bindTable(':table_orders', TABLE_ORDERS);
134       $Qorder->bindInt(':orders_id', $order_id);
135       $Qorder->execute();
hpdl
1
136
hpdl
20
137       $Qtotals = $osC_Database->query('select title, text, class from :table_orders_total where orders_id = :orders_id order by sort_order');
138       $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
139       $Qtotals->bindInt(':orders_id', $order_id);
140       $Qtotals->execute();
hpdl
1
141
hpdl
20
142       $shipping_method_string = '';
143       $order_total_string = '';
hpdl
1
144
hpdl
20
145       while ($Qtotals->next()) {
146         $this->totals[] = array('title' => $Qtotals->value('title'),
147                                 'text' => $Qtotals->value('text'));
hpdl
1
148
hpdl
20
149         if ($Qtotals->value('class') == 'ot_shipping') {
150           $shipping_method_string = strip_tags($Qtotals->value('title'));
hpdl
1
151
hpdl
20
152           if (substr($shipping_method_string, -1) == ':') {
153             $shipping_method_string = substr($Qtotals->value('title'), 0, -1);
154           }
155         }
hpdl
1
156
hpdl
20
157         if ($Qtotals->value('class') == 'ot_total') {
158           $order_total_string = strip_tags($Qtotals->value('text'));
159         }
160       }
hpdl
1
161
hpdl
20
162       $Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id');
163       $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
hpdl
46
164       $Qstatus->bindInt(':orders_status_id', $Qorder->valueInt('orders_status'));
hpdl
383
165       $Qstatus->bindInt(':language_id', $osC_Language->getID());
hpdl
20
166       $Qstatus->execute();
hpdl
1
167
hpdl
20
168       $this->info = array('currency' => $Qorder->value('currency'),
169                           'currency_value' => $Qorder->value('currency_value'),
170                           'payment_method' => $Qorder->value('payment_method'),
171                           'cc_type' => $Qorder->value('cc_type'),
172                           'cc_owner' => $Qorder->valueProtected('cc_owner'),
173                           'cc_number' => $Qorder->valueProtected('cc_number'),
174                           'cc_expires' => $Qorder->valueProtected('cc_expires'),
175                           'date_purchased' => $Qorder->value('date_purchased'),
176                           'orders_status' => $Qstatus->value('orders_status_name'),
177                           'last_modified' => $Qorder->value('last_modified'),
178                           'total' => $order_total_string,
179                           'shipping_method' => $shipping_method_string);
hpdl
1
180
hpdl
20
181       $this->customer = array('id' => $Qorder->valueInt('customers_id'),
182                               'name' => $Qorder->valueProtected('customers_name'),
183                               'company' => $Qorder->valueProtected('customers_company'),
184                               'street_address' => $Qorder->valueProtected('customers_street_address'),
185                               'suburb' => $Qorder->valueProtected('customers_suburb'),
186                               'city' => $Qorder->valueProtected('customers_city'),
187                               'postcode' => $Qorder->valueProtected('customers_postcode'),
188                               'state' => $Qorder->valueProtected('customers_state'),
189                               'country' => $Qorder->valueProtected('customers_country'),
190                               'format_id' => $Qorder->valueInt('customers_address_format_id'),
191                               'telephone' => $Qorder->valueProtected('customers_telephone'),
192                               'email_address' => $Qorder->valueProtected('customers_email_address'));
193
194       $this->delivery = array('name' => $Qorder->valueProtected('delivery_name'),
195                               'company' => $Qorder->valueProtected('delivery_company'),
196                               'street_address' => $Qorder->valueProtected('delivery_street_address'),
197                               'suburb' => $Qorder->valueProtected('delivery_suburb'),
198                               'city' => $Qorder->valueProtected('delivery_city'),
199                               'postcode' => $Qorder->valueProtected('delivery_postcode'),
200                               'state' => $Qorder->valueProtected('delivery_state'),
201                               'country' => $Qorder->valueProtected('delivery_country'),
202                               'format_id' => $Qorder->valueInt('delivery_address_format_id'));
203
hpdl
1
204       if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) {
205         $this->delivery = false;
206       }
207
hpdl
20
208       $this->billing = array('name' => $Qorder->valueProtected('billing_name'),
209                              'company' => $Qorder->valueProtected('billing_company'),
210                              'street_address' => $Qorder->valueProtected('billing_street_address'),
211                              'suburb' => $Qorder->valueProtected('billing_suburb'),
212                              'city' => $Qorder->valueProtected('billing_city'),
213                              'postcode' => $Qorder->valueProtected('billing_postcode'),
214                              'state' => $Qorder->valueProtected('billing_state'),
215                              'country' => $Qorder->valueProtected('billing_country'),
216                              'format_id' => $Qorder->valueInt('billing_address_format_id'));
hpdl
1
217
hpdl
20
218       $Qproducts = $osC_Database->query('select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from :table_orders_products where orders_id = :orders_id');
219       $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
220       $Qproducts->bindInt(':orders_id', $order_id);
221       $Qproducts->execute();
222
hpdl
1
223       $index = 0;
224
hpdl
20
225       while ($Qproducts->next()) {
hpdl
1
226         $subindex = 0;
227
hpdl
20
228         $this->products[$index] = array('qty' => $Qproducts->valueInt('products_quantity'),
229                                         'id' => $Qproducts->valueInt('products_id'),
230                                         'name' => $Qproducts->value('products_name'),
231                                         'model' => $Qproducts->value('products_model'),
232                                         'tax' => $Qproducts->value('products_tax'),
233                                         'price' => $Qproducts->value('products_price'),
234                                         'final_price' => $Qproducts->value('final_price'));
235
236         $Qattributes = $osC_Database->query('select products_options, products_options_values, options_values_price, price_prefix from :table_orders_products_attributes where orders_id = :orders_id and orders_products_id = :orders_products_id');
237         $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES);
238         $Qattributes->bindInt(':orders_id', $order_id);
239         $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id'));
240         $Qattributes->execute();
241
242         if ($Qattributes->numberOfRows()) {
243           while ($Qattributes->next()) {
244             $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options'),
245                                                                      'value' => $Qattributes->value('products_options_values'),
246                                                                      'prefix' => $Qattributes->value('price_prefix'),
247                                                                      'price' => $Qattributes->value('options_values_price'));
248
hpdl
1
249             $subindex++;
250           }
251         }
252
253         $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1';
254
255         $index++;
256       }
257     }
258
259     function cart() {
hpdl
383
260       global $osC_Database, $osC_Customer, $osC_Tax, $osC_Currencies, $osC_Language;
hpdl
1
261
hpdl
368
262       $this->content_type = $_SESSION['cart']->get_content_type();
hpdl
1
263
hpdl
368
264       $shipping =& $_SESSION['shipping'];
265       $payment =& $_SESSION['payment'];
hpdl
1
266
hpdl
20
267       $Qcustomer = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from :table_customers c, :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries co on (ab.entry_country_id = co.countries_id) where c.customers_id = :customers_id and ab.customers_id = :customers_id and c.customers_default_address_id = ab.address_book_id');
268       $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
269       $Qcustomer->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
270       $Qcustomer->bindTable(':table_zones', TABLE_ZONES);
271       $Qcustomer->bindTable(':table_countries', TABLE_COUNTRIES);
hpdl
368
272       $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
273       $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
hpdl
20
274       $Qcustomer->execute();
hpdl
1
275
hpdl
20
276       $Qshipping = $osC_Database->query('select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries c on (ab.entry_country_id = c.countries_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
277       $Qshipping->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
278       $Qshipping->bindTable(':table_zones', TABLE_ZONES);
279       $Qshipping->bindTable(':table_countries', TABLE_COUNTRIES);
hpdl
368
280       $Qshipping->bindInt(':customers_id', $osC_Customer->getID());
281       $Qshipping->bindInt(':address_book_id', $_SESSION['sendto']);
hpdl
20
282       $Qshipping->execute();
hpdl
1
283
hpdl
20
284       $Qbilling = $osC_Database->query('select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) left join :table_countries c on (ab.entry_country_id = c.countries_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
285       $Qbilling->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
286       $Qbilling->bindTable(':table_zones', TABLE_ZONES);
287       $Qbilling->bindTable(':table_countries', TABLE_COUNTRIES);
hpdl
368
288       $Qbilling->bindInt(':customers_id', $osC_Customer->getID());
289       $Qbilling->bindInt(':address_book_id', $_SESSION['billto']);
hpdl
20
290       $Qbilling->execute();
hpdl
1
291
hpdl
20
292       $Qtax = $osC_Database->query('select ab.entry_country_id, ab.entry_zone_id from :table_address_book ab left join :table_zones z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = :customers_id and ab.address_book_id = :address_book_id');
293       $Qtax->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
294       $Qtax->bindTable(':table_zones', TABLE_ZONES);
hpdl
368
295       $Qtax->bindInt(':customers_id', $osC_Customer->getID());
296       $Qtax->bindInt(':address_book_id', ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']));
hpdl
20
297       $Qtax->execute();
hpdl
1
298
299       $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,
hpdl
368
300                           'currency' => $_SESSION['currency'],
301                           'currency_value' => $osC_Currencies->currencies[$_SESSION['currency']]['value'],
hpdl
1
302                           'payment_method' => $payment,
303                           'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''),
304                           'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''),
305                           'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''),
306                           'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''),
307                           'shipping_method' => $shipping['title'],
308                           'shipping_cost' => $shipping['cost'],
309                           'subtotal' => 0,
310                           'tax' => 0,
311                           'tax_groups' => array(),
hpdl
368
312                           'comments' => (isset($_SESSION['comments']) ? $_SESSION['comments'] : ''));
hpdl
1
313
314       if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) {
315         $this->info['payment_method'] = $GLOBALS[$payment]->title;
316
317         if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) {
318           $this->info['order_status'] = $GLOBALS[$payment]->order_status;
319         }
320       }
321
hpdl
20
322       $this->customer = array('firstname' => $Qcustomer->valueProtected('customers_firstname'),
323                               'lastname' => $Qcustomer->valueProtected('customers_lastname'),
324                               'company' => $Qcustomer->valueProtected('entry_company'),
325                               'street_address' => $Qcustomer->valueProtected('entry_street_address'),
326                               'suburb' => $Qcustomer->valueProtected('entry_suburb'),
327                               'city' => $Qcustomer->valueProtected('entry_city'),
328                               'postcode' => $Qcustomer->valueProtected('entry_postcode'),
329                               'state' => (tep_not_null($Qcustomer->valueProtected('entry_state')) ? $Qcustomer->valueProtected('entry_state') : $Qcustomer->valueProtected('zone_name')),
330                               'zone_id' => $Qcustomer->valueInt('entry_zone_id'),
331                               'country' => array('id' => $Qcustomer->valueInt('countries_id'), 'title' => $Qcustomer->value('countries_name'), 'iso_code_2' => $Qcustomer->value('countries_iso_code_2'), 'iso_code_3' => $Qcustomer->value('countries_iso_code_3')),
332                               'format_id' => $Qcustomer->valueInt('address_format_id'),
333                               'telephone' => $Qcustomer->valueProtected('customers_telephone'),
334                               'email_address' => $Qcustomer->valueProtected('customers_email_address'));
hpdl
1
335
hpdl
20
336       $this->delivery = array('firstname' => $Qshipping->valueProtected('entry_firstname'),
337                               'lastname' => $Qshipping->valueProtected('entry_lastname'),
338                               'company' => $Qshipping->valueProtected('entry_company'),
339                               'street_address' => $Qshipping->valueProtected('entry_street_address'),
340                               'suburb' => $Qshipping->valueProtected('entry_suburb'),
341                               'city' => $Qshipping->valueProtected('entry_city'),
342                               'postcode' => $Qshipping->valueProtected('entry_postcode'),
343                               'state' => (tep_not_null($Qshipping->valueProtected('entry_state')) ? $Qshipping->valueProtected('entry_state') : $Qshipping->valueProtected('zone_name')),
344                               'zone_id' => $Qshipping->valueInt('entry_zone_id'),
345                               'country' => array('id' => $Qshipping->valueInt('countries_id'), 'title' => $Qshipping->value('countries_name'), 'iso_code_2' => $Qshipping->value('countries_iso_code_2'), 'iso_code_3' => $Qshipping->value('countries_iso_code_3')),
346                               'country_id' => $Qshipping->valueInt('entry_country_id'),
347                               'format_id' => $Qshipping->valueInt('address_format_id'));
hpdl
1
348
hpdl
20
349       $this->billing = array('firstname' => $Qbilling->valueProtected('entry_firstname'),
350                              'lastname' => $Qbilling->valueProtected('entry_lastname'),
351                              'company' => $Qbilling->valueProtected('entry_company'),
352                              'street_address' => $Qbilling->valueProtected('entry_street_address'),
353                              'suburb' => $Qbilling->valueProtected('entry_suburb'),
354                              'city' => $Qbilling->valueProtected('entry_city'),
355                              'postcode' => $Qbilling->valueProtected('entry_postcode'),
356                              'state' => (tep_not_null($Qbilling->valueProtected('entry_state')) ? $Qbilling->valueProtected('entry_state') : $Qbilling->valueProtected('zone_name')),
357                              'zone_id' => $Qbilling->valueInt('entry_zone_id'),
358                              'country' => array('id' => $Qbilling->valueInt('countries_id'), 'title' => $Qbilling->value('countries_name'), 'iso_code_2' => $Qbilling->value('countries_iso_code_2'), 'iso_code_3' => $Qbilling->value('countries_iso_code_3')),
359                              'country_id' => $Qbilling->valueInt('entry_country_id'),
360                              'format_id' => $Qbilling->valueInt('address_format_id'));
hpdl
1
361
362       $index = 0;
hpdl
368
363       $products = $_SESSION['cart']->get_products();
hpdl
1
364       for ($i=0, $n=sizeof($products); $i<$n; $i++) {
365         $this->products[$index] = array('qty' => $products[$i]['quantity'],
366                                         'name' => $products[$i]['name'],
367                                         'model' => $products[$i]['model'],
hpdl
20
368                                         'tax' => $osC_Tax->getTaxRate($products[$i]['tax_class_id'], $Qtax->valueInt('entry_country_id'), $Qtax->valueInt('entry_zone_id')),
369                                         'tax_description' => $osC_Tax->getTaxRateDescription($products[$i]['tax_class_id'], $Qtax->valueInt('entry_country_id'), $Qtax->valueInt('entry_zone_id')),
hpdl
1
370                                         'tax_class_id' => $products[$i]['tax_class_id'],
371                                         'price' => $products[$i]['price'],
hpdl
368
372                                         'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']),
hpdl
1
373                                         'weight' => $products[$i]['weight'],
374                                         'id' => $products[$i]['id']);
375
376         if ($products[$i]['attributes']) {
377           $subindex = 0;
378           reset($products[$i]['attributes']);
379           while (list($option, $value) = each($products[$i]['attributes'])) {
hpdl
20
380             $Qattributes = $osC_Database->query('select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from :table_products_options popt, :table_products_options_values poval, :table_products_attributes pa where pa.products_id = :products_id and pa.options_id = :options_id and pa.options_id = popt.products_options_id and pa.options_values_id = :options_values_id and pa.options_values_id = poval.products_options_values_id and popt.language_id = :language_id and poval.language_id = :language_id');
381             $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS);
382             $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES);
383             $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
384             $Qattributes->bindInt(':products_id', $products[$i]['id']);
385             $Qattributes->bindInt(':options_id', $option);
386             $Qattributes->bindInt(':options_values_id', $value);
hpdl
383
387             $Qattributes->bindInt(':language_id', $osC_Language->getID());
388             $Qattributes->bindInt(':language_id', $osC_Language->getID());
hpdl
20
389             $Qattributes->execute();
hpdl
1
390
hpdl
20
391             $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options_name'),
392                                                                      'value' => $Qattributes->value('products_options_values_name'),
hpdl
1
393                                                                      'option_id' => $option,
394                                                                      'value_id' => $value,
hpdl
20
395                                                                      'prefix' => $Qattributes->value('price_prefix'),
396                                                                      'price' => $Qattributes->value('options_values_price'));
hpdl
1
397
398             $subindex++;
399           }
400         }
401
402         $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'];
403         $this->info['subtotal'] += $shown_price;
404
405         $products_tax = $this->products[$index]['tax'];
406         $products_tax_description = $this->products[$index]['tax_description'];
407         if (DISPLAY_PRICE_WITH_TAX == 'true') {
408           $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
409           if (isset($this->info['tax_groups']["$products_tax_description"])) {
410             $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
411           } else {
412             $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
413           }
414         } else {
415           $this->info['tax'] += ($products_tax / 100) * $shown_price;
416           if (isset($this->info['tax_groups']["$products_tax_description"])) {
417             $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price;
418           } else {
419             $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price;
420           }
421         }
422
423         $index++;
424       }
425
426       if (DISPLAY_PRICE_WITH_TAX == 'true') {
427         $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
428       } else {
429         $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
430       }
431     }
432   }
433 ?>