  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: order.php 1498 2007-03-29 14:04:50Z hpdl $ |
| |
| 3 | + | $Id: order.php 1862 2009-03-06 23:34:07Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
7 | 7 | | |
  |
8 | | - | Copyright (c) 2006 osCommerce |
| |
| 8 | + | Copyright (c) 2007 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | This program is free software; you can redistribute it and/or modify |
| |
11 | 11 | | it under the terms of the GNU General Public License v2 (1991) |
| |
|
|
 |
… |
|
21 | 21 | | |
| |
22 | 22 | | /* Class constructor */ |
| |
23 | 23 | | |
  |
24 | | - | function osC_Order($order_id = '') { |
| |
| 24 | + | function __construct($order_id = '') { |
|
25 | 25 | | if (is_numeric($order_id)) { |
| |
26 | 26 | | $this->_id = $order_id; |
| |
27 | 27 | | } |
| |
|
|
 |
… |
|
65 | 65 | | $Qcheck->execute(); |
| |
66 | 66 | | |
| |
67 | 67 | | if ($Qcheck->valueInt('orders_status') === 4) { |
  |
| 68 | + | /* HPDL |
|
68 | 69 | | $Qdel = $osC_Database->query('delete from :table_orders_products_download where orders_id = :orders_id'); |
| |
69 | 70 | | $Qdel->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); |
| |
70 | 71 | | $Qdel->bindInt(':orders_id', $id); |
| |
71 | 72 | | $Qdel->execute(); |
  |
| 73 | + | */ |
|
72 | 74 | | |
  |
73 | | - | $Qdel = $osC_Database->query('delete from :table_orders_products_attributes where orders_id = :orders_id'); |
| |
74 | | - | $Qdel->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES); |
| |
| 75 | + | $Qdel = $osC_Database->query('delete from :table_orders_products_variants where orders_id = :orders_id'); |
| |
| 76 | + | $Qdel->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); |
|
75 | 77 | | $Qdel->bindInt(':orders_id', $id); |
| |
76 | 78 | | $Qdel->execute(); |
| |
77 | 79 | | |
| |
|
|
 |
… |
|
188 | 190 | | $Qstatus->execute(); |
| |
189 | 191 | | |
| |
190 | 192 | | foreach ($osC_ShoppingCart->getProducts() as $products) { |
  |
191 | | - | $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_model, products_name, products_price, final_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_model, :products_name, :products_price, :final_price, :products_tax, :products_quantity)'); |
| |
| 193 | + | $Qproducts = $osC_Database->query('insert into :table_orders_products (orders_id, products_id, products_model, products_name, products_price, products_tax, products_quantity) values (:orders_id, :products_id, :products_model, :products_name, :products_price, :products_tax, :products_quantity)'); |
|
192 | 194 | | $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); |
| |
193 | 195 | | $Qproducts->bindInt(':orders_id', $insert_id); |
| |
194 | 196 | | $Qproducts->bindInt(':products_id', osc_get_product_id($products['id'])); |
| |
195 | 197 | | $Qproducts->bindValue(':products_model', '' /*$products['model']*/); |
| |
196 | 198 | | $Qproducts->bindValue(':products_name', $products['name']); |
| |
197 | 199 | | $Qproducts->bindValue(':products_price', $products['price']); |
  |
198 | | - | $Qproducts->bindValue(':final_price', $products['final_price']); |
|
199 | 200 | | $Qproducts->bindValue(':products_tax', '' /*$products['tax']*/); |
| |
200 | 201 | | $Qproducts->bindInt(':products_quantity', $products['quantity']); |
| |
201 | 202 | | $Qproducts->execute(); |
| |
202 | 203 | | |
| |
203 | 204 | | $order_products_id = $osC_Database->nextID(); |
| |
204 | 205 | | |
  |
205 | | - | if ($osC_ShoppingCart->hasAttributes($products['id'])) { |
| |
206 | | - | foreach ($osC_ShoppingCart->getAttributes($products['id']) as $attributes) { |
| |
| 206 | + | if ( $osC_ShoppingCart->isVariant($products['id']) ) { |
| |
| 207 | + | foreach ( $osC_ShoppingCart->getVariant($products['id']) as $variant ) { |
| |
| 208 | + | /* HPDL |
|
207 | 209 | | if (DOWNLOAD_ENABLED == '1') { |
| |
208 | 210 | | $Qattributes = $osC_Database->query('select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount, pad.products_attributes_filename from :table_products_options popt, :table_products_options_values poval, :table_products_attributes pa left join :table_products_attributes_download pad on (pa.products_attributes_id = pad.products_attributes_id) 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 = :popt_language_id and poval.language_id = :poval_language_id'); |
| |
209 | 211 | | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
|
|
 |
… |
|
215 | 217 | | $Qattributes->bindInt(':options_values_id', $attributes['options_values_id']); |
| |
216 | 218 | | $Qattributes->bindInt(':popt_language_id', $osC_Language->getID()); |
| |
217 | 219 | | $Qattributes->bindInt(':poval_language_id', $osC_Language->getID()); |
  |
218 | | - | } else { |
| |
219 | | - | $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 = :popt_language_id and poval.language_id = :poval_language_id'); |
| |
220 | | - | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
221 | | - | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
222 | | - | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
223 | | - | $Qattributes->bindInt(':products_id', $products['id']); |
| |
224 | | - | $Qattributes->bindInt(':options_id', $attributes['options_id']); |
| |
225 | | - | $Qattributes->bindInt(':options_values_id', $attributes['options_values_id']); |
| |
226 | | - | $Qattributes->bindInt(':popt_language_id', $osC_Language->getID()); |
| |
227 | | - | $Qattributes->bindInt(':poval_language_id', $osC_Language->getID()); |
| |
| 220 | + | $Qattributes->execute(); |
|
228 | 221 | | } |
  |
229 | | - | $Qattributes->execute(); |
| |
| 222 | + | */ |
|
230 | 223 | | |
  |
231 | | - | $Qopa = $osC_Database->query('insert into :table_orders_products_attributes (orders_id, orders_products_id, products_options, products_options_values, options_values_price, price_prefix) values (:orders_id, :orders_products_id, :products_options, :products_options_values, :options_values_price, :price_prefix)'); |
| |
232 | | - | $Qopa->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES); |
| |
233 | | - | $Qopa->bindInt(':orders_id', $insert_id); |
| |
234 | | - | $Qopa->bindInt(':orders_products_id', $order_products_id); |
| |
235 | | - | $Qopa->bindValue(':products_options', $Qattributes->value('products_options_name')); |
| |
236 | | - | $Qopa->bindValue(':products_options_values', $Qattributes->value('products_options_values_name')); |
| |
237 | | - | $Qopa->bindValue(':options_values_price', $Qattributes->value('options_values_price')); |
| |
238 | | - | $Qopa->bindValue(':price_prefix', $Qattributes->value('price_prefix')); |
| |
239 | | - | $Qopa->execute(); |
| |
| 224 | + | $Qvariant = $osC_Database->query('insert into :table_orders_products_variants (orders_id, orders_products_id, group_title, value_title) values (:orders_id, :orders_products_id, :group_title, :value_title)'); |
| |
| 225 | + | $Qvariant->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); |
| |
| 226 | + | $Qvariant->bindInt(':orders_id', $insert_id); |
| |
| 227 | + | $Qvariant->bindInt(':orders_products_id', $order_products_id); |
| |
| 228 | + | $Qvariant->bindValue(':group_title', $variant['group_title']); |
| |
| 229 | + | $Qvariant->bindValue(':value_title', $variant['value_title']); |
| |
| 230 | + | $Qvariant->execute(); |
|
240 | 231 | | |
  |
| 232 | + | /*HPDL |
|
241 | 233 | | if ((DOWNLOAD_ENABLED == '1') && (strlen($Qattributes->value('products_attributes_filename')) > 0)) { |
| |
242 | 234 | | $Qopd = $osC_Database->query('insert into :table_orders_products_download (orders_id, orders_products_id, orders_products_filename, download_maxdays, download_count) values (:orders_id, :orders_products_id, :orders_products_filename, :download_maxdays, :download_count)'); |
| |
243 | 235 | | $Qopd->bindTable(':table_orders_products_download', TABLE_ORDERS_PRODUCTS_DOWNLOAD); |
| |
|
|
 |
… |
|
248 | 240 | | $Qopd->bindValue(':download_count', $Qattributes->value('products_attributes_maxcount')); |
| |
249 | 241 | | $Qopd->execute(); |
| |
250 | 242 | | } |
  |
| 243 | + | */ |
|
251 | 244 | | } |
| |
252 | 245 | | } |
| |
253 | 246 | | } |
| |
|
|
 |
… |
|
365 | 358 | | $osC_Language->get('email_order_products') . "\n" . |
| |
366 | 359 | | $osC_Language->get('email_order_separator') . "\n"; |
| |
367 | 360 | | |
  |
368 | | - | $Qproducts = $osC_Database->query('select orders_products_id, products_model, products_name, final_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id'); |
| |
| 361 | + | $Qproducts = $osC_Database->query('select orders_products_id, products_model, products_name, products_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id order by orders_products_id'); |
|
369 | 362 | | $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); |
| |
370 | 363 | | $Qproducts->bindInt(':orders_id', $id); |
| |
371 | 364 | | $Qproducts->execute(); |
| |
372 | 365 | | |
| |
373 | 366 | | while ($Qproducts->next()) { |
  |
374 | | - | $email_order .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $Qproducts->value('products_model') . ') = ' . $osC_Currencies->displayPriceWithTaxRate($Qproducts->value('final_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n"; |
| |
| 367 | + | $email_order .= $Qproducts->valueInt('products_quantity') . ' x ' . $Qproducts->value('products_name') . ' (' . $Qproducts->value('products_model') . ') = ' . $osC_Currencies->displayPriceWithTaxRate($Qproducts->value('products_price'), $Qproducts->value('products_tax'), $Qproducts->valueInt('products_quantity'), $Qorder->value('currency'), $Qorder->value('currency_value')) . "\n"; |
|
375 | 368 | | |
  |
376 | | - | $Qattributes = $osC_Database->query('select products_options, products_options_values from :table_orders_products_attributes where orders_id = :orders_id and orders_products_id = :orders_products_id order by orders_products_attributes_id'); |
| |
377 | | - | $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES); |
| |
378 | | - | $Qattributes->bindInt(':orders_id', $id); |
| |
379 | | - | $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); |
| |
380 | | - | $Qattributes->execute(); |
| |
| 369 | + | $Qvariants = $osC_Database->query('select group_title, value_title from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id order by id'); |
| |
| 370 | + | $Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); |
| |
| 371 | + | $Qvariants->bindInt(':orders_id', $id); |
| |
| 372 | + | $Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); |
| |
| 373 | + | $Qvariants->execute(); |
|
381 | 374 | | |
  |
382 | | - | while ($Qattributes->next()) { |
| |
383 | | - | $email_order .= "\t" . $Qattributes->value('products_options') . ': ' . $Qattributes->value('products_options_values') . "\n"; |
| |
| 375 | + | while ( $Qvariants->next() ) { |
| |
| 376 | + | $email_order .= "\t" . $Qvariants->value('group_title') . ': ' . $Qvariants->value('value_title') . "\n"; |
|
384 | 377 | | } |
| |
385 | 378 | | } |
| |
386 | 379 | | |
| |
387 | 380 | | unset($Qproducts); |
  |
388 | | - | unset($Qattributes); |
| |
| 381 | + | unset($Qvariants); |
|
389 | 382 | | |
| |
390 | 383 | | $email_order .= $osC_Language->get('email_order_separator') . "\n"; |
| |
391 | 384 | | |
| |
|
|
 |
… |
|
416 | 409 | | |
| |
417 | 410 | | $email_order .= "\n" . $osC_Language->get('email_order_delivery_address') . "\n" . |
| |
418 | 411 | | $osC_Language->get('email_order_separator') . "\n" . |
  |
419 | | - | osC_Address::format($address, "\n") . "\n"; |
| |
| 412 | + | osC_Address::format($address) . "\n"; |
|
420 | 413 | | |
| |
421 | 414 | | unset($address); |
| |
422 | 415 | | } |
| |
|
|
 |
… |
|
436 | 429 | | |
| |
437 | 430 | | $email_order .= "\n" . $osC_Language->get('email_order_billing_address') . "\n" . |
| |
438 | 431 | | $osC_Language->get('email_order_separator') . "\n" . |
  |
439 | | - | osC_Address::format($address, "\n") . "\n\n"; |
| |
| 432 | + | osC_Address::format($address) . "\n\n"; |
|
440 | 433 | | |
| |
441 | 434 | | unset($address); |
| |
442 | 435 | | |
| |
|
|
 |
… |
|
680 | 673 | | 'country_iso3' => $Qorder->value('billing_country_iso3'), |
| |
681 | 674 | | 'format' => $Qorder->value('billing_address_format')); |
| |
682 | 675 | | |
  |
683 | | - | $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'); |
| |
| 676 | + | $Qproducts = $osC_Database->query('select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity from :table_orders_products where orders_id = :orders_id'); |
|
684 | 677 | | $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); |
| |
685 | 678 | | $Qproducts->bindInt(':orders_id', $order_id); |
| |
686 | 679 | | $Qproducts->execute(); |
| |
|
|
 |
… |
|
695 | 688 | | 'name' => $Qproducts->value('products_name'), |
| |
696 | 689 | | 'model' => $Qproducts->value('products_model'), |
| |
697 | 690 | | 'tax' => $Qproducts->value('products_tax'), |
  |
698 | | - | 'price' => $Qproducts->value('products_price'), |
| |
699 | | - | 'final_price' => $Qproducts->value('final_price')); |
| |
| 691 | + | 'price' => $Qproducts->value('products_price')); |
|
700 | 692 | | |
  |
701 | | - | $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'); |
| |
702 | | - | $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES); |
| |
703 | | - | $Qattributes->bindInt(':orders_id', $order_id); |
| |
704 | | - | $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); |
| |
705 | | - | $Qattributes->execute(); |
| |
| 693 | + | $Qvariants = $osC_Database->query('select group_title, value_title from :table_orders_products_variants where orders_id = :orders_id and orders_products_id = :orders_products_id order by id'); |
| |
| 694 | + | $Qvariants->bindTable(':table_orders_products_variants', TABLE_ORDERS_PRODUCTS_VARIANTS); |
| |
| 695 | + | $Qvariants->bindInt(':orders_id', $order_id); |
| |
| 696 | + | $Qvariants->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); |
| |
| 697 | + | $Qvariants->execute(); |
|
706 | 698 | | |
  |
707 | | - | if ($Qattributes->numberOfRows()) { |
| |
708 | | - | while ($Qattributes->next()) { |
| |
709 | | - | $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options'), |
| |
710 | | - | 'value' => $Qattributes->value('products_options_values'), |
| |
711 | | - | 'prefix' => $Qattributes->value('price_prefix'), |
| |
712 | | - | 'price' => $Qattributes->value('options_values_price')); |
| |
| 699 | + | if ( $Qvariants->numberOfRows() ) { |
| |
| 700 | + | while ( $Qvariants->next() ) { |
| |
| 701 | + | $this->products[$index]['attributes'][$subindex] = array('option' => $Qvariants->value('group_title'), |
| |
| 702 | + | 'value' => $Qvariants->value('value_title')); |
  |
713 | 703 | | |
| |
714 | 704 | | $subindex++; |
| |
715 | 705 | | } |