  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: order.php 5 2005-01-31 01:40:15Z hpdl $ |
| |
| 3 | + | $Id: order.php 20 2005-02-25 18:34:41Z 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) 2005 osCommerce |
|
9 | 9 | | |
| |
10 | 10 | | Released under the GNU General Public License |
| |
11 | 11 | | */ |
| |
|
|
 |
… |
|
28 | 28 | | } |
| |
29 | 29 | | |
| |
30 | 30 | | function query($order_id) { |
  |
31 | | - | global $osC_Session; |
| |
| 31 | + | global $osC_Database, $osC_Session; |
|
32 | 32 | | |
  |
33 | | - | $order_id = tep_db_prepare_input($order_id); |
| |
| 33 | + | $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'); |
| |
| 34 | + | $Qorder->bindTable(':table_orders', TABLE_ORDERS); |
| |
| 35 | + | $Qorder->bindInt(':orders_id', $order_id); |
| |
| 36 | + | $Qorder->execute(); |
|
34 | 37 | | |
  |
35 | | - | $order_query = tep_db_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 = '" . (int)$order_id . "'"); |
| |
36 | | - | $order = tep_db_fetch_array($order_query); |
| |
| 38 | + | $Qtotals = $osC_Database->query('select title, text, class from :table_orders_total where orders_id = :orders_id order by sort_order'); |
| |
| 39 | + | $Qtotals->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL); |
| |
| 40 | + | $Qtotals->bindInt(':orders_id', $order_id); |
| |
| 41 | + | $Qtotals->execute(); |
|
37 | 42 | | |
  |
38 | | - | $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); |
| |
39 | | - | while ($totals = tep_db_fetch_array($totals_query)) { |
| |
40 | | - | $this->totals[] = array('title' => $totals['title'], |
| |
41 | | - | 'text' => $totals['text']); |
| |
42 | | - | } |
| |
| 43 | + | $shipping_method_string = ''; |
| |
| 44 | + | $order_total_string = ''; |
|
43 | 45 | | |
  |
44 | | - | $order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'"); |
| |
45 | | - | $order_total = tep_db_fetch_array($order_total_query); |
| |
| 46 | + | while ($Qtotals->next()) { |
| |
| 47 | + | $this->totals[] = array('title' => $Qtotals->value('title'), |
| |
| 48 | + | 'text' => $Qtotals->value('text')); |
|
46 | 49 | | |
  |
47 | | - | $shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'"); |
| |
48 | | - | $shipping_method = tep_db_fetch_array($shipping_method_query); |
| |
| 50 | + | if ($Qtotals->value('class') == 'ot_shipping') { |
| |
| 51 | + | $shipping_method_string = strip_tags($Qtotals->value('title')); |
|
49 | 52 | | |
  |
50 | | - | $order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$osC_Session->value('languages_id') . "'"); |
| |
51 | | - | $order_status = tep_db_fetch_array($order_status_query); |
| |
| 53 | + | if (substr($shipping_method_string, -1) == ':') { |
| |
| 54 | + | $shipping_method_string = substr($Qtotals->value('title'), 0, -1); |
| |
| 55 | + | } |
| |
| 56 | + | } |
|
52 | 57 | | |
  |
53 | | - | $this->info = array('currency' => $order['currency'], |
| |
54 | | - | 'currency_value' => $order['currency_value'], |
| |
55 | | - | 'payment_method' => $order['payment_method'], |
| |
56 | | - | 'cc_type' => $order['cc_type'], |
| |
57 | | - | 'cc_owner' => $order['cc_owner'], |
| |
58 | | - | 'cc_number' => $order['cc_number'], |
| |
59 | | - | 'cc_expires' => $order['cc_expires'], |
| |
60 | | - | 'date_purchased' => $order['date_purchased'], |
| |
61 | | - | 'orders_status' => $order_status['orders_status_name'], |
| |
62 | | - | 'last_modified' => $order['last_modified'], |
| |
63 | | - | 'total' => strip_tags($order_total['text']), |
| |
64 | | - | 'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title']))); |
| |
| 58 | + | if ($Qtotals->value('class') == 'ot_total') { |
| |
| 59 | + | $order_total_string = strip_tags($Qtotals->value('text')); |
| |
| 60 | + | } |
| |
| 61 | + | } |
|
65 | 62 | | |
  |
66 | | - | $this->customer = array('id' => $order['customers_id'], |
| |
67 | | - | 'name' => $order['customers_name'], |
| |
68 | | - | 'company' => $order['customers_company'], |
| |
69 | | - | 'street_address' => $order['customers_street_address'], |
| |
70 | | - | 'suburb' => $order['customers_suburb'], |
| |
71 | | - | 'city' => $order['customers_city'], |
| |
72 | | - | 'postcode' => $order['customers_postcode'], |
| |
73 | | - | 'state' => $order['customers_state'], |
| |
74 | | - | 'country' => $order['customers_country'], |
| |
75 | | - | 'format_id' => $order['customers_address_format_id'], |
| |
76 | | - | 'telephone' => $order['customers_telephone'], |
| |
77 | | - | 'email_address' => $order['customers_email_address']); |
| |
| 63 | + | $Qstatus = $osC_Database->query('select orders_status_name from :table_orders_status where orders_status_id = :orders_status_id and language_id = :language_id'); |
| |
| 64 | + | $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS); |
| |
| 65 | + | $Qstatus->bindInt(':orders_status', $Qorder->valueInt('orders_status')); |
| |
| 66 | + | $Qstatus->bindInt(':language_id', $osC_Session->value('languages_id')); |
| |
| 67 | + | $Qstatus->execute(); |
|
78 | 68 | | |
  |
79 | | - | $this->delivery = array('name' => $order['delivery_name'], |
| |
80 | | - | 'company' => $order['delivery_company'], |
| |
81 | | - | 'street_address' => $order['delivery_street_address'], |
| |
82 | | - | 'suburb' => $order['delivery_suburb'], |
| |
83 | | - | 'city' => $order['delivery_city'], |
| |
84 | | - | 'postcode' => $order['delivery_postcode'], |
| |
85 | | - | 'state' => $order['delivery_state'], |
| |
86 | | - | 'country' => $order['delivery_country'], |
| |
87 | | - | 'format_id' => $order['delivery_address_format_id']); |
| |
| 69 | + | $this->info = array('currency' => $Qorder->value('currency'), |
| |
| 70 | + | 'currency_value' => $Qorder->value('currency_value'), |
| |
| 71 | + | 'payment_method' => $Qorder->value('payment_method'), |
| |
| 72 | + | 'cc_type' => $Qorder->value('cc_type'), |
| |
| 73 | + | 'cc_owner' => $Qorder->valueProtected('cc_owner'), |
| |
| 74 | + | 'cc_number' => $Qorder->valueProtected('cc_number'), |
| |
| 75 | + | 'cc_expires' => $Qorder->valueProtected('cc_expires'), |
| |
| 76 | + | 'date_purchased' => $Qorder->value('date_purchased'), |
| |
| 77 | + | 'orders_status' => $Qstatus->value('orders_status_name'), |
| |
| 78 | + | 'last_modified' => $Qorder->value('last_modified'), |
| |
| 79 | + | 'total' => $order_total_string, |
| |
| 80 | + | 'shipping_method' => $shipping_method_string); |
|
88 | 81 | | |
  |
| 82 | + | $this->customer = array('id' => $Qorder->valueInt('customers_id'), |
| |
| 83 | + | 'name' => $Qorder->valueProtected('customers_name'), |
| |
| 84 | + | 'company' => $Qorder->valueProtected('customers_company'), |
| |
| 85 | + | 'street_address' => $Qorder->valueProtected('customers_street_address'), |
| |
| 86 | + | 'suburb' => $Qorder->valueProtected('customers_suburb'), |
| |
| 87 | + | 'city' => $Qorder->valueProtected('customers_city'), |
| |
| 88 | + | 'postcode' => $Qorder->valueProtected('customers_postcode'), |
| |
| 89 | + | 'state' => $Qorder->valueProtected('customers_state'), |
| |
| 90 | + | 'country' => $Qorder->valueProtected('customers_country'), |
| |
| 91 | + | 'format_id' => $Qorder->valueInt('customers_address_format_id'), |
| |
| 92 | + | 'telephone' => $Qorder->valueProtected('customers_telephone'), |
| |
| 93 | + | 'email_address' => $Qorder->valueProtected('customers_email_address')); |
| |
| 94 | + | |
| |
| 95 | + | $this->delivery = array('name' => $Qorder->valueProtected('delivery_name'), |
| |
| 96 | + | 'company' => $Qorder->valueProtected('delivery_company'), |
| |
| 97 | + | 'street_address' => $Qorder->valueProtected('delivery_street_address'), |
| |
| 98 | + | 'suburb' => $Qorder->valueProtected('delivery_suburb'), |
| |
| 99 | + | 'city' => $Qorder->valueProtected('delivery_city'), |
| |
| 100 | + | 'postcode' => $Qorder->valueProtected('delivery_postcode'), |
| |
| 101 | + | 'state' => $Qorder->valueProtected('delivery_state'), |
| |
| 102 | + | 'country' => $Qorder->valueProtected('delivery_country'), |
| |
| 103 | + | 'format_id' => $Qorder->valueInt('delivery_address_format_id')); |
| |
| 104 | + | |
|
89 | 105 | | if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) { |
| |
90 | 106 | | $this->delivery = false; |
| |
91 | 107 | | } |
| |
92 | 108 | | |
  |
93 | | - | $this->billing = array('name' => $order['billing_name'], |
| |
94 | | - | 'company' => $order['billing_company'], |
| |
95 | | - | 'street_address' => $order['billing_street_address'], |
| |
96 | | - | 'suburb' => $order['billing_suburb'], |
| |
97 | | - | 'city' => $order['billing_city'], |
| |
98 | | - | 'postcode' => $order['billing_postcode'], |
| |
99 | | - | 'state' => $order['billing_state'], |
| |
100 | | - | 'country' => $order['billing_country'], |
| |
101 | | - | 'format_id' => $order['billing_address_format_id']); |
| |
| 109 | + | $this->billing = array('name' => $Qorder->valueProtected('billing_name'), |
| |
| 110 | + | 'company' => $Qorder->valueProtected('billing_company'), |
| |
| 111 | + | 'street_address' => $Qorder->valueProtected('billing_street_address'), |
| |
| 112 | + | 'suburb' => $Qorder->valueProtected('billing_suburb'), |
| |
| 113 | + | 'city' => $Qorder->valueProtected('billing_city'), |
| |
| 114 | + | 'postcode' => $Qorder->valueProtected('billing_postcode'), |
| |
| 115 | + | 'state' => $Qorder->valueProtected('billing_state'), |
| |
| 116 | + | 'country' => $Qorder->valueProtected('billing_country'), |
| |
| 117 | + | 'format_id' => $Qorder->valueInt('billing_address_format_id')); |
|
102 | 118 | | |
  |
| 119 | + | $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'); |
| |
| 120 | + | $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); |
| |
| 121 | + | $Qproducts->bindInt(':orders_id', $order_id); |
| |
| 122 | + | $Qproducts->execute(); |
| |
| 123 | + | |
|
103 | 124 | | $index = 0; |
  |
104 | | - | $orders_products_query = tep_db_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 = '" . (int)$order_id . "'"); |
| |
105 | | - | while ($orders_products = tep_db_fetch_array($orders_products_query)) { |
| |
106 | | - | $this->products[$index] = array('qty' => $orders_products['products_quantity'], |
| |
107 | | - | 'id' => $orders_products['products_id'], |
| |
108 | | - | 'name' => $orders_products['products_name'], |
| |
109 | | - | 'model' => $orders_products['products_model'], |
| |
110 | | - | 'tax' => $orders_products['products_tax'], |
| |
111 | | - | 'price' => $orders_products['products_price'], |
| |
112 | | - | 'final_price' => $orders_products['final_price']); |
|
113 | 125 | | |
  |
| 126 | + | while ($Qproducts->next()) { |
|
114 | 127 | | $subindex = 0; |
  |
115 | | - | $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); |
| |
116 | | - | if (tep_db_num_rows($attributes_query)) { |
| |
117 | | - | while ($attributes = tep_db_fetch_array($attributes_query)) { |
| |
118 | | - | $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], |
| |
119 | | - | 'value' => $attributes['products_options_values'], |
| |
120 | | - | 'prefix' => $attributes['price_prefix'], |
| |
121 | | - | 'price' => $attributes['options_values_price']); |
|
122 | 128 | | |
  |
| 129 | + | $this->products[$index] = array('qty' => $Qproducts->valueInt('products_quantity'), |
| |
| 130 | + | 'id' => $Qproducts->valueInt('products_id'), |
| |
| 131 | + | 'name' => $Qproducts->value('products_name'), |
| |
| 132 | + | 'model' => $Qproducts->value('products_model'), |
| |
| 133 | + | 'tax' => $Qproducts->value('products_tax'), |
| |
| 134 | + | 'price' => $Qproducts->value('products_price'), |
| |
| 135 | + | 'final_price' => $Qproducts->value('final_price')); |
| |
| 136 | + | |
| |
| 137 | + | $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'); |
| |
| 138 | + | $Qattributes->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES); |
| |
| 139 | + | $Qattributes->bindInt(':orders_id', $order_id); |
| |
| 140 | + | $Qattributes->bindInt(':orders_products_id', $Qproducts->valueInt('orders_products_id')); |
| |
| 141 | + | $Qattributes->execute(); |
| |
| 142 | + | |
| |
| 143 | + | if ($Qattributes->numberOfRows()) { |
| |
| 144 | + | while ($Qattributes->next()) { |
| |
| 145 | + | $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options'), |
| |
| 146 | + | 'value' => $Qattributes->value('products_options_values'), |
| |
| 147 | + | 'prefix' => $Qattributes->value('price_prefix'), |
| |
| 148 | + | 'price' => $Qattributes->value('options_values_price')); |
| |
| 149 | + | |
|
123 | 150 | | $subindex++; |
| |
124 | 151 | | } |
| |
125 | 152 | | } |
| |
|
|
 |
… |
|
131 | 158 | | } |
| |
132 | 159 | | |
| |
133 | 160 | | function cart() { |
  |
134 | | - | global $osC_Session, $osC_Customer, $osC_Tax, $cart, $osC_Currencies; |
| |
| 161 | + | global $osC_Database, $osC_Session, $osC_Customer, $osC_Tax, $cart, $osC_Currencies; |
|
135 | 162 | | |
| |
136 | 163 | | $this->content_type = $cart->get_content_type(); |
| |
137 | 164 | | |
| |
138 | 165 | | $shipping =& $osC_Session->value('shipping'); |
| |
139 | 166 | | $payment =& $osC_Session->value('payment'); |
| |
140 | 167 | | |
  |
141 | | - | $customer_address_query = tep_db_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 = '" . (int)$osC_Customer->id . "' and ab.customers_id = '" . (int)$osC_Customer->id . "' and c.customers_default_address_id = ab.address_book_id"); |
| |
142 | | - | $customer_address = tep_db_fetch_array($customer_address_query); |
| |
| 168 | + | $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'); |
| |
| 169 | + | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
| |
| 170 | + | $Qcustomer->bindTable(':table_address_book', TABLE_ADDRESS_BOOK); |
| |
| 171 | + | $Qcustomer->bindTable(':table_zones', TABLE_ZONES); |
| |
| 172 | + | $Qcustomer->bindTable(':table_countries', TABLE_COUNTRIES); |
| |
| 173 | + | $Qcustomer->bindInt(':customers_id', $osC_Customer->id); |
| |
| 174 | + | $Qcustomer->bindInt(':customers_id', $osC_Customer->id); |
| |
| 175 | + | $Qcustomer->execute(); |
|
143 | 176 | | |
  |
144 | | - | $shipping_address_query = tep_db_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 = '" . (int)$osC_Customer->id . "' and ab.address_book_id = '" . (int)$osC_Session->value('sendto') . "'"); |
| |
145 | | - | $shipping_address = tep_db_fetch_array($shipping_address_query); |
| |
| 177 | + | $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'); |
| |
| 178 | + | $Qshipping->bindTable(':table_address_book', TABLE_ADDRESS_BOOK); |
| |
| 179 | + | $Qshipping->bindTable(':table_zones', TABLE_ZONES); |
| |
| 180 | + | $Qshipping->bindTable(':table_countries', TABLE_COUNTRIES); |
| |
| 181 | + | $Qshipping->bindInt(':customers_id', $osC_Customer->id); |
| |
| 182 | + | $Qshipping->bindInt(':address_book_id', $osC_Session->value('sendto')); |
| |
| 183 | + | $Qshipping->execute(); |
|
146 | 184 | | |
  |
147 | | - | $billing_address_query = tep_db_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 = '" . (int)$osC_Customer->id . "' and ab.address_book_id = '" . (int)$osC_Session->value('billto') . "'"); |
| |
148 | | - | $billing_address = tep_db_fetch_array($billing_address_query); |
| |
| 185 | + | $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'); |
| |
| 186 | + | $Qbilling->bindTable(':table_address_book', TABLE_ADDRESS_BOOK); |
| |
| 187 | + | $Qbilling->bindTable(':table_zones', TABLE_ZONES); |
| |
| 188 | + | $Qbilling->bindTable(':table_countries', TABLE_COUNTRIES); |
| |
| 189 | + | $Qbilling->bindInt(':customers_id', $osC_Customer->id); |
| |
| 190 | + | $Qbilling->bindInt(':address_book_id', $osC_Session->value('billto')); |
| |
| 191 | + | $Qbilling->execute(); |
|
149 | 192 | | |
  |
150 | | - | $tax_address_query = tep_db_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 = '" . (int)$osC_Customer->id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $osC_Session->value('billto') : $osC_Session->value('sendto')) . "'"); |
| |
151 | | - | $tax_address = tep_db_fetch_array($tax_address_query); |
| |
| 193 | + | $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'); |
| |
| 194 | + | $Qtax->bindTable(':table_address_book', TABLE_ADDRESS_BOOK); |
| |
| 195 | + | $Qtax->bindTable(':table_zones', TABLE_ZONES); |
| |
| 196 | + | $Qtax->bindInt(':customers_id', $osC_Customer->id); |
| |
| 197 | + | $Qtax->bindInt(':address_book_id', ($this->content_type == 'virtual' ? $osC_Session->value('billto') : $osC_Session->value('sendto'))); |
| |
| 198 | + | $Qtax->execute(); |
|
152 | 199 | | |
| |
153 | 200 | | $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, |
| |
154 | 201 | | 'currency' => $osC_Session->value('currency'), |
| |
|
|
 |
… |
|
173 | 220 | | } |
| |
174 | 221 | | } |
| |
175 | 222 | | |
  |
176 | | - | $this->customer = array('firstname' => $customer_address['customers_firstname'], |
| |
177 | | - | 'lastname' => $customer_address['customers_lastname'], |
| |
178 | | - | 'company' => $customer_address['entry_company'], |
| |
179 | | - | 'street_address' => $customer_address['entry_street_address'], |
| |
180 | | - | 'suburb' => $customer_address['entry_suburb'], |
| |
181 | | - | 'city' => $customer_address['entry_city'], |
| |
182 | | - | 'postcode' => $customer_address['entry_postcode'], |
| |
183 | | - | 'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']), |
| |
184 | | - | 'zone_id' => $customer_address['entry_zone_id'], |
| |
185 | | - | 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), |
| |
186 | | - | 'format_id' => $customer_address['address_format_id'], |
| |
187 | | - | 'telephone' => $customer_address['customers_telephone'], |
| |
188 | | - | 'email_address' => $customer_address['customers_email_address']); |
| |
| 223 | + | $this->customer = array('firstname' => $Qcustomer->valueProtected('customers_firstname'), |
| |
| 224 | + | 'lastname' => $Qcustomer->valueProtected('customers_lastname'), |
| |
| 225 | + | 'company' => $Qcustomer->valueProtected('entry_company'), |
| |
| 226 | + | 'street_address' => $Qcustomer->valueProtected('entry_street_address'), |
| |
| 227 | + | 'suburb' => $Qcustomer->valueProtected('entry_suburb'), |
| |
| 228 | + | 'city' => $Qcustomer->valueProtected('entry_city'), |
| |
| 229 | + | 'postcode' => $Qcustomer->valueProtected('entry_postcode'), |
| |
| 230 | + | 'state' => (tep_not_null($Qcustomer->valueProtected('entry_state')) ? $Qcustomer->valueProtected('entry_state') : $Qcustomer->valueProtected('zone_name')), |
| |
| 231 | + | 'zone_id' => $Qcustomer->valueInt('entry_zone_id'), |
| |
| 232 | + | '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')), |
| |
| 233 | + | 'format_id' => $Qcustomer->valueInt('address_format_id'), |
| |
| 234 | + | 'telephone' => $Qcustomer->valueProtected('customers_telephone'), |
| |
| 235 | + | 'email_address' => $Qcustomer->valueProtected('customers_email_address')); |
|
189 | 236 | | |
  |
190 | | - | $this->delivery = array('firstname' => $shipping_address['entry_firstname'], |
| |
191 | | - | 'lastname' => $shipping_address['entry_lastname'], |
| |
192 | | - | 'company' => $shipping_address['entry_company'], |
| |
193 | | - | 'street_address' => $shipping_address['entry_street_address'], |
| |
194 | | - | 'suburb' => $shipping_address['entry_suburb'], |
| |
195 | | - | 'city' => $shipping_address['entry_city'], |
| |
196 | | - | 'postcode' => $shipping_address['entry_postcode'], |
| |
197 | | - | 'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']), |
| |
198 | | - | 'zone_id' => $shipping_address['entry_zone_id'], |
| |
199 | | - | 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), |
| |
200 | | - | 'country_id' => $shipping_address['entry_country_id'], |
| |
201 | | - | 'format_id' => $shipping_address['address_format_id']); |
| |
| 237 | + | $this->delivery = array('firstname' => $Qshipping->valueProtected('entry_firstname'), |
| |
| 238 | + | 'lastname' => $Qshipping->valueProtected('entry_lastname'), |
| |
| 239 | + | 'company' => $Qshipping->valueProtected('entry_company'), |
| |
| 240 | + | 'street_address' => $Qshipping->valueProtected('entry_street_address'), |
| |
| 241 | + | 'suburb' => $Qshipping->valueProtected('entry_suburb'), |
| |
| 242 | + | 'city' => $Qshipping->valueProtected('entry_city'), |
| |
| 243 | + | 'postcode' => $Qshipping->valueProtected('entry_postcode'), |
| |
| 244 | + | 'state' => (tep_not_null($Qshipping->valueProtected('entry_state')) ? $Qshipping->valueProtected('entry_state') : $Qshipping->valueProtected('zone_name')), |
| |
| 245 | + | 'zone_id' => $Qshipping->valueInt('entry_zone_id'), |
| |
| 246 | + | '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')), |
| |
| 247 | + | 'country_id' => $Qshipping->valueInt('entry_country_id'), |
| |
| 248 | + | 'format_id' => $Qshipping->valueInt('address_format_id')); |
|
202 | 249 | | |
  |
203 | | - | $this->billing = array('firstname' => $billing_address['entry_firstname'], |
| |
204 | | - | 'lastname' => $billing_address['entry_lastname'], |
| |
205 | | - | 'company' => $billing_address['entry_company'], |
| |
206 | | - | 'street_address' => $billing_address['entry_street_address'], |
| |
207 | | - | 'suburb' => $billing_address['entry_suburb'], |
| |
208 | | - | 'city' => $billing_address['entry_city'], |
| |
209 | | - | 'postcode' => $billing_address['entry_postcode'], |
| |
210 | | - | 'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']), |
| |
211 | | - | 'zone_id' => $billing_address['entry_zone_id'], |
| |
212 | | - | 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), |
| |
213 | | - | 'country_id' => $billing_address['entry_country_id'], |
| |
214 | | - | 'format_id' => $billing_address['address_format_id']); |
| |
| 250 | + | $this->billing = array('firstname' => $Qbilling->valueProtected('entry_firstname'), |
| |
| 251 | + | 'lastname' => $Qbilling->valueProtected('entry_lastname'), |
| |
| 252 | + | 'company' => $Qbilling->valueProtected('entry_company'), |
| |
| 253 | + | 'street_address' => $Qbilling->valueProtected('entry_street_address'), |
| |
| 254 | + | 'suburb' => $Qbilling->valueProtected('entry_suburb'), |
| |
| 255 | + | 'city' => $Qbilling->valueProtected('entry_city'), |
| |
| 256 | + | 'postcode' => $Qbilling->valueProtected('entry_postcode'), |
| |
| 257 | + | 'state' => (tep_not_null($Qbilling->valueProtected('entry_state')) ? $Qbilling->valueProtected('entry_state') : $Qbilling->valueProtected('zone_name')), |
| |
| 258 | + | 'zone_id' => $Qbilling->valueInt('entry_zone_id'), |
| |
| 259 | + | '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')), |
| |
| 260 | + | 'country_id' => $Qbilling->valueInt('entry_country_id'), |
| |
| 261 | + | 'format_id' => $Qbilling->valueInt('address_format_id')); |
|
215 | 262 | | |
| |
216 | 263 | | $index = 0; |
| |
217 | 264 | | $products = $cart->get_products(); |
| |
218 | 265 | | for ($i=0, $n=sizeof($products); $i<$n; $i++) { |
| |
219 | 266 | | $this->products[$index] = array('qty' => $products[$i]['quantity'], |
| |
220 | 267 | | 'name' => $products[$i]['name'], |
| |
221 | 268 | | 'model' => $products[$i]['model'], |
  |
222 | | - | 'tax' => $osC_Tax->getTaxRate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), |
| |
223 | | - | 'tax_description' => $osC_Tax->getTaxRateDescription($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), |
| |
| 269 | + | 'tax' => $osC_Tax->getTaxRate($products[$i]['tax_class_id'], $Qtax->valueInt('entry_country_id'), $Qtax->valueInt('entry_zone_id')), |
| |
| 270 | + | 'tax_description' => $osC_Tax->getTaxRateDescription($products[$i]['tax_class_id'], $Qtax->valueInt('entry_country_id'), $Qtax->valueInt('entry_zone_id')), |
|
224 | 271 | | 'tax_class_id' => $products[$i]['tax_class_id'], |
| |
225 | 272 | | 'price' => $products[$i]['price'], |
| |
226 | 273 | | 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), |
| |
|
|
 |
… |
|
231 | 278 | | $subindex = 0; |
| |
232 | 279 | | reset($products[$i]['attributes']); |
| |
233 | 280 | | while (list($option, $value) = each($products[$i]['attributes'])) { |
  |
234 | | - | $attributes_query = tep_db_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 = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$osC_Session->value('languages_id') . "' and poval.language_id = '" . (int)$osC_Session->value('languages_id') . "'"); |
| |
235 | | - | $attributes = tep_db_fetch_array($attributes_query); |
| |
| 281 | + | $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'); |
| |
| 282 | + | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
| 283 | + | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
| 284 | + | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
| 285 | + | $Qattributes->bindInt(':products_id', $products[$i]['id']); |
| |
| 286 | + | $Qattributes->bindInt(':options_id', $option); |
| |
| 287 | + | $Qattributes->bindInt(':options_values_id', $value); |
| |
| 288 | + | $Qattributes->bindInt(':language_id', $osC_Session->value('languages_id')); |
| |
| 289 | + | $Qattributes->bindInt(':language_id', $osC_Session->value('languages_id')); |
| |
| 290 | + | $Qattributes->execute(); |
|
236 | 291 | | |
  |
237 | | - | $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], |
| |
238 | | - | 'value' => $attributes['products_options_values_name'], |
| |
| 292 | + | $this->products[$index]['attributes'][$subindex] = array('option' => $Qattributes->value('products_options_name'), |
| |
| 293 | + | 'value' => $Qattributes->value('products_options_values_name'), |
|
239 | 294 | | 'option_id' => $option, |
| |
240 | 295 | | 'value_id' => $value, |
  |
241 | | - | 'prefix' => $attributes['price_prefix'], |
| |
242 | | - | 'price' => $attributes['options_values_price']); |
| |
| 296 | + | 'prefix' => $Qattributes->value('price_prefix'), |
| |
| 297 | + | 'price' => $Qattributes->value('options_values_price')); |
  |
243 | 298 | | |
| |
244 | 299 | | $subindex++; |
| |
245 | 300 | | } |