  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: shopping_cart.php 748 2006-08-23 11:26:56Z hpdl $ |
| |
| 3 | + | $Id: shopping_cart.php 809 2006-08-27 01:02:21Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
22 | 22 | | $_products_in_stock = true; |
| |
23 | 23 | | |
| |
24 | 24 | | function osC_ShoppingCart() { |
  |
25 | | - | if (isset($_SESSION['osC_ShoppingCart_data']) === false) { |
| |
| 25 | + | if (!isset($_SESSION['osC_ShoppingCart_data'])) { |
|
26 | 26 | | $_SESSION['osC_ShoppingCart_data'] = array('contents' => array(), |
| |
27 | 27 | | 'sub_total_cost' => 0, |
| |
28 | 28 | | 'total_cost' => 0, |
| |
|
|
 |
… |
|
63 | 63 | | } |
| |
64 | 64 | | |
| |
65 | 65 | | function synchronizeWithDatabase() { |
  |
66 | | - | global $osC_Database, $osC_Language, $osC_Customer, $osC_Image; |
| |
| 66 | + | global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image; |
|
67 | 67 | | |
  |
68 | | - | if ($osC_Customer->isLoggedOn() === false) { |
| |
| 68 | + | if (!$osC_Customer->isLoggedOn()) { |
|
69 | 69 | | return false; |
| |
70 | 70 | | } |
| |
71 | 71 | | |
| |
72 | 72 | | // insert current cart contents in database |
| |
73 | 73 | | if ($this->hasContents()) { |
  |
74 | | - | foreach ($this->_contents as $products_id => $data) { |
| |
| 74 | + | foreach ($this->_contents as $products_id_string => $data) { |
|
75 | 75 | | $Qproduct = $osC_Database->query('select products_id, customers_basket_quantity from :table_customers_basket where customers_id = :customers_id and products_id = :products_id'); |
| |
76 | 76 | | $Qproduct->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
77 | 77 | | $Qproduct->bindInt(':customers_id', $osC_Customer->getID()); |
  |
78 | | - | $Qproduct->bindValue(':products_id', $products_id); |
| |
| 78 | + | $Qproduct->bindValue(':products_id', $products_id_string); |
|
79 | 79 | | $Qproduct->execute(); |
| |
80 | 80 | | |
| |
81 | 81 | | if ($Qproduct->numberOfRows() > 0) { |
| |
82 | 82 | | $Qupdate = $osC_Database->query('update :table_customers_basket set customers_basket_quantity = :customers_basket_quantity where customers_id = :customers_id and products_id = :products_id'); |
| |
83 | 83 | | $Qupdate->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
84 | 84 | | $Qupdate->bindInt(':customers_basket_quantity', $data['quantity'] + $Qproduct->valueInt('customers_basket_quantity')); |
| |
85 | 85 | | $Qupdate->bindInt(':customers_id', $osC_Customer->getID()); |
  |
86 | | - | $Qupdate->bindValue(':products_id', $products_id); |
| |
| 86 | + | $Qupdate->bindValue(':products_id', $products_id_string); |
|
87 | 87 | | $Qupdate->execute(); |
| |
88 | 88 | | } else { |
| |
89 | 89 | | $Qnew = $osC_Database->query('insert into :table_customers_basket (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values (:customers_id, :products_id, :customers_basket_quantity, now())'); |
| |
90 | 90 | | $Qnew->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
91 | 91 | | $Qnew->bindInt(':customers_id', $osC_Customer->getID()); |
  |
92 | | - | $Qnew->bindValue(':products_id', $products_id); |
| |
| 92 | + | $Qnew->bindValue(':products_id', $products_id_string); |
|
93 | 93 | | $Qnew->bindInt(':customers_basket_quantity', $data['quantity']); |
| |
94 | 94 | | $Qnew->execute(); |
  |
95 | | - | |
| |
96 | | - | if (isset($data['attributes'])) { |
| |
97 | | - | foreach ($data['attributes'] as $option => $value) { |
| |
98 | | - | $Qnew = $osC_Database->query('insert into :table_customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) values (:customers_id, :products_id, :products_options_id, :products_options_value_id)'); |
| |
99 | | - | $Qnew->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
100 | | - | $Qnew->bindInt(':customers_id', $osC_Customer->getID()); |
| |
101 | | - | $Qnew->bindValue(':products_id', $products_id); |
| |
102 | | - | $Qnew->bindInt(':products_options_id', $option); |
| |
103 | | - | $Qnew->bindInt(':products_options_value_id', $value['options_values_id']); |
| |
104 | | - | $Qnew->execute(); |
| |
105 | | - | } |
| |
106 | | - | } |
|
107 | 95 | | } |
| |
108 | 96 | | } |
| |
109 | 97 | | } |
| |
|
|
 |
… |
|
122 | 110 | | $Qproducts->execute(); |
| |
123 | 111 | | |
| |
124 | 112 | | while ($Qproducts->next()) { |
  |
| 113 | + | $product = explode('#', $Qproducts->value('products_id'), 2); |
| |
| 114 | + | $attributes_array = array(); |
| |
| 115 | + | |
| |
| 116 | + | if (isset($product[1])) { |
| |
| 117 | + | $attributes = explode(';', $product[1]); |
| |
| 118 | + | |
| |
| 119 | + | foreach ($attributes as $set) { |
| |
| 120 | + | $attribute = explode(':', $set); |
| |
| 121 | + | |
| |
| 122 | + | if (!is_numeric($attribute[0]) || !is_numeric($attribute[1])) { |
| |
| 123 | + | continue 2; // skip product |
| |
| 124 | + | } |
| |
| 125 | + | |
| |
| 126 | + | $attributes_array[$attribute[0]] = $attribute[1]; |
| |
| 127 | + | } |
| |
| 128 | + | } |
| |
| 129 | + | |
|
125 | 130 | | $price = $Qproducts->value('products_price'); |
| |
126 | 131 | | |
  |
127 | | - | $Qspecials = $osC_Database->query('select specials_new_products_price from :table_specials where products_id = :products_id and status = 1'); |
| |
128 | | - | $Qspecials->bindTable(':table_specials', TABLE_SPECIALS); |
| |
129 | | - | $Qspecials->bindInt(':products_id', osc_get_product_id($Qproducts->value('products_id'))); |
| |
130 | | - | $Qspecials->execute(); |
| |
| 132 | + | if ($osC_Services->isStarted('specials')) { |
| |
| 133 | + | global $osC_Specials; |
|
131 | 134 | | |
  |
132 | | - | if ($Qspecials->numberOfRows() > 0) { |
| |
133 | | - | $price = $Qspecials->value('specials_new_products_price'); |
| |
| 135 | + | if ($new_price = $osC_Specials->getPrice(osc_get_product_id($Qproducts->value('products_id')))) { |
| |
| 136 | + | $price = $new_price; |
| |
| 137 | + | } |
|
134 | 138 | | } |
| |
135 | 139 | | |
| |
136 | 140 | | $this->_contents[$Qproducts->value('products_id')] = array('id' => $Qproducts->value('products_id'), |
| |
|
|
 |
… |
|
145 | 149 | | 'date_added' => osC_DateTime::getShort($Qproducts->value('customers_basket_date_added')), |
| |
146 | 150 | | 'weight_class_id' => $Qproducts->valueInt('products_weight_class')); |
| |
147 | 151 | | |
  |
148 | | - | $Qattributes = $osC_Database->query('select cba.products_options_id, cba.products_options_value_id, po.products_options_name, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from :table_customers_basket_attributes cba, :table_products_options po, :table_products_options_values pov, :table_products_attributes pa where cba.customers_id = 1 and cba.products_id = :products_id and pa.products_id = :products_id and cba.products_options_id = pa.options_id and pa.options_id = po.products_options_id and po.language_id = :language_id and cba.products_options_value_id = pa.options_values_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id'); |
| |
149 | | - | $Qattributes->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
150 | | - | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
151 | | - | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
152 | | - | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
153 | | - | $Qattributes->bindInt(':customers_id', $osC_Customer->getID()); |
| |
154 | | - | $Qattributes->bindValue(':products_id', $Qproducts->value('products_id')); |
| |
155 | | - | $Qattributes->bindInt(':products_id', osc_get_product_id($Qproducts->value('products_id'))); |
| |
156 | | - | $Qattributes->bindInt(':language_id', $osC_Language->getID()); |
| |
157 | | - | $Qattributes->bindInt(':language_id', $osC_Language->getID()); |
| |
158 | | - | $Qattributes->execute(); |
| |
| 152 | + | if (!empty($attributes_array)) { |
| |
| 153 | + | foreach ($attributes_array as $option_id => $value_id) { |
| |
| 154 | + | $Qattributes = $osC_Database->query('select pa.options_values_price, pa.price_prefix, po.products_options_name, pov.products_options_values_name from :table_products_attributes pa, :table_products_options po, :table_products_options_values pov where pa.products_id = :products_id and pa.options_id = :options_id and pa.options_values_id = :options_values_id and pa.options_id = po.products_options_id and po.language_id = :language_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id'); |
| |
| 155 | + | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
| 156 | + | $Qattributes->bindTable(':table_products_options', TABLE_PRODUCTS_OPTIONS); |
| |
| 157 | + | $Qattributes->bindTable(':table_products_options_values', TABLE_PRODUCTS_OPTIONS_VALUES); |
| |
| 158 | + | $Qattributes->bindInt(':products_id', osc_get_product_id($Qproducts->value('products_id'))); |
| |
| 159 | + | $Qattributes->bindInt(':options_id', $option_id); |
| |
| 160 | + | $Qattributes->bindInt(':options_values_id', $value_id); |
| |
| 161 | + | $Qattributes->bindInt(':language_id', $osC_Language->getID()); |
| |
| 162 | + | $Qattributes->bindInt(':language_id', $osC_Language->getID()); |
| |
| 163 | + | $Qattributes->execute(); |
|
159 | 164 | | |
  |
160 | | - | while ($Qattributes->next()) { |
| |
161 | | - | $this->_contents[$Qproducts->value('products_id')]['attributes'][$Qattributes->valueInt('products_options_id')] = array('options_id' => $Qattributes->valueInt('products_options_id'), |
| |
162 | | - | 'options_values_id' => $Qattributes->valueInt('products_options_value_id'), |
| |
163 | | - | 'products_options_name' => $Qattributes->value('products_options_name'), |
| |
164 | | - | 'products_options_values_name' => $Qattributes->value('products_options_values_name'), |
| |
165 | | - | 'options_values_price' => $Qattributes->value('options_values_price'), |
| |
166 | | - | 'price_prefix' => $Qattributes->value('price_prefix')); |
| |
| 165 | + | while ($Qattributes->next()) { |
| |
| 166 | + | $this->_contents[$Qproducts->value('products_id')]['attributes'][$option_id] = array('options_id' => $option_id, |
| |
| 167 | + | 'options_values_id' => $value_id, |
| |
| 168 | + | 'products_options_name' => $Qattributes->value('products_options_name'), |
| |
| 169 | + | 'products_options_values_name' => $Qattributes->value('products_options_values_name'), |
| |
| 170 | + | 'options_values_price' => $Qattributes->value('options_values_price'), |
| |
| 171 | + | 'price_prefix' => $Qattributes->value('price_prefix')); |
|
167 | 172 | | |
  |
168 | | - | if ($Qattributes->value('price_prefix') == '+') { |
| |
169 | | - | $this->_contents[$Qproducts->value('products_id')]['final_price'] += $Qattributes->value('options_values_price'); |
| |
170 | | - | } else { |
| |
171 | | - | $this->_contents[$Qproducts->value('products_id')]['final_price'] -= $Qattributes->value('options_values_price'); |
| |
| 173 | + | if ($Qattributes->value('price_prefix') == '+') { |
| |
| 174 | + | $this->_contents[$Qproducts->value('products_id')]['final_price'] += $Qattributes->value('options_values_price'); |
| |
| 175 | + | } else { |
| |
| 176 | + | $this->_contents[$Qproducts->value('products_id')]['final_price'] -= $Qattributes->value('options_values_price'); |
| |
| 177 | + | } |
| |
| 178 | + | } |
|
172 | 179 | | } |
| |
173 | 180 | | } |
| |
174 | 181 | | } |
| |
|
|
 |
… |
|
181 | 188 | | global $osC_Database, $osC_Customer; |
| |
182 | 189 | | |
| |
183 | 190 | | if (($reset_database === true) && $osC_Customer->isLoggedOn()) { |
  |
184 | | - | $Qcheck = $osC_Database->query('select customers_basket_attributes_id from :table_customers_basket_attributes where customers_id = :customers_id limit 1'); |
| |
185 | | - | $Qcheck->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
186 | | - | $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); |
| |
187 | | - | $Qcheck->execute(); |
| |
188 | | - | |
| |
189 | | - | if ($Qcheck->numberOfRows() > 0) { |
| |
190 | | - | $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id'); |
| |
191 | | - | $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
192 | | - | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
193 | | - | $Qdelete->execute(); |
| |
194 | | - | } |
| |
195 | | - | |
|
196 | 191 | | $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id'); |
| |
197 | 192 | | $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
198 | 193 | | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
|
|
 |
… |
|
214 | 209 | | $this->resetBillingMethod(); |
| |
215 | 210 | | } |
| |
216 | 211 | | |
  |
217 | | - | function add($products_id, $attributes = '', $quantity = '') { |
| |
218 | | - | global $osC_Database, $osC_Language, $osC_Customer, $osC_Image; |
| |
| 212 | + | function add($products_id_string, $attributes = null, $quantity = null) { |
| |
| 213 | + | global $osC_Database, $osC_Services, $osC_Language, $osC_Customer, $osC_Image; |
|
219 | 214 | | |
  |
220 | | - | $products_id_string = osc_get_product_id_string($products_id, $attributes); |
| |
| 215 | + | $products_id_string = osc_get_product_id_string($products_id_string, $attributes); |
|
221 | 216 | | $products_id = osc_get_product_id($products_id_string); |
| |
222 | 217 | | |
| |
223 | 218 | | if (is_numeric($products_id)) { |
| |
|
|
 |
… |
|
230 | 225 | | |
| |
231 | 226 | | if ($Qcheck->valueInt('products_status') === 1) { |
| |
232 | 227 | | if ($this->exists($products_id_string)) { |
  |
233 | | - | if (is_numeric($quantity) === false) { |
| |
| 228 | + | if (!is_numeric($quantity)) { |
|
234 | 229 | | $quantity = $this->getQuantity($products_id_string) + 1; |
| |
235 | 230 | | } |
| |
236 | 231 | | |
| |
|
|
 |
… |
|
246 | 241 | | $Qupdate->execute(); |
| |
247 | 242 | | } |
| |
248 | 243 | | } else { |
  |
249 | | - | if (is_numeric($quantity) === false) { |
| |
| 244 | + | if (!is_numeric($quantity)) { |
|
250 | 245 | | $quantity = 1; |
| |
251 | 246 | | } |
| |
252 | 247 | | |
| |
|
|
 |
… |
|
258 | 253 | | |
| |
259 | 254 | | $price = $Qcheck->value('products_price'); |
| |
260 | 255 | | |
  |
261 | | - | $Qspecials = $osC_Database->query('select specials_new_products_price from :table_specials where products_id = :products_id and status = 1'); |
| |
262 | | - | $Qspecials->bindTable(':table_specials', TABLE_SPECIALS); |
| |
263 | | - | $Qspecials->bindInt(':products_id', $products_id); |
| |
264 | | - | $Qspecials->execute(); |
| |
| 256 | + | if ($osC_Services->isStarted('specials')) { |
| |
| 257 | + | global $osC_Specials; |
|
265 | 258 | | |
  |
266 | | - | if ($Qspecials->numberOfRows() > 0) { |
| |
267 | | - | $price = $Qspecials->value('specials_new_products_price'); |
| |
| 259 | + | if ($new_price = $osC_Specials->getPrice($products_id)) { |
| |
| 260 | + | $price = $new_price; |
| |
| 261 | + | } |
|
268 | 262 | | } |
| |
269 | 263 | | |
| |
270 | 264 | | $this->_contents[$products_id_string] = array('id' => $products_id_string, |
| |
|
|
 |
… |
|
289 | 283 | | $Qnew->execute(); |
| |
290 | 284 | | } |
| |
291 | 285 | | |
  |
292 | | - | if (is_array($attributes) && (empty($attributes) === false)) { |
| |
| 286 | + | if (is_array($attributes) && !empty($attributes)) { |
|
293 | 287 | | foreach ($attributes as $option => $value) { |
| |
294 | 288 | | $Qattributes = $osC_Database->query('select pa.options_values_price, pa.price_prefix, po.products_options_name, pov.products_options_values_name from :table_products_attributes pa, :table_products_options po, :table_products_options_values pov where pa.products_id = :products_id and pa.options_id = :options_id and pa.options_values_id = :options_values_id and pa.options_id = po.products_options_id and po.language_id = :language_id and pa.options_values_id = pov.products_options_values_id and pov.language_id = :language_id'); |
| |
295 | 289 | | $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); |
| |
|
|
 |
… |
|
314 | 308 | | } else { |
| |
315 | 309 | | $this->_contents[$products_id_string]['final_price'] -= $Qattributes->value('options_values_price'); |
| |
316 | 310 | | } |
  |
317 | | - | |
| |
318 | | - | // insert into database |
| |
319 | | - | if ($osC_Customer->isLoggedOn()) { |
| |
320 | | - | $Qnew = $osC_Database->query('insert into :table_customers_basket_attributes (customers_id, products_id, products_options_id, products_options_value_id) values (:customers_id, :products_id, :products_options_id, :products_options_value_id)'); |
| |
321 | | - | $Qnew->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
322 | | - | $Qnew->bindInt(':customers_id', $osC_Customer->getID()); |
| |
323 | | - | $Qnew->bindValue(':products_id', $products_id_string); |
| |
324 | | - | $Qnew->bindInt(':products_options_id', $option); |
| |
325 | | - | $Qnew->bindInt(':products_options_value_id', $value); |
| |
326 | | - | $Qnew->execute(); |
| |
327 | | - | } |
|
328 | 311 | | } |
| |
329 | 312 | | } |
| |
330 | 313 | | } |
| |
|
|
 |
… |
|
366 | 349 | | |
| |
367 | 350 | | // remove from database |
| |
368 | 351 | | if ($osC_Customer->isLoggedOn()) { |
  |
369 | | - | $Qcheck = $osC_Database->query('select customers_basket_attributes_id from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id limit 1'); |
| |
370 | | - | $Qcheck->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
371 | | - | $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); |
| |
372 | | - | $Qcheck->bindValue(':products_id', $products_id); |
| |
373 | | - | $Qcheck->execute(); |
| |
374 | | - | |
| |
375 | | - | if ($Qcheck->numberOfRows() > 0) { |
| |
376 | | - | $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id'); |
| |
377 | | - | $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
378 | | - | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
379 | | - | $Qdelete->bindValue(':products_id', $products_id); |
| |
380 | | - | $Qdelete->execute(); |
| |
381 | | - | } |
| |
382 | | - | |
|
383 | 352 | | $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id and products_id = :products_id'); |
| |
384 | 353 | | $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
385 | 354 | | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
|
|
 |
… |
|
485 | 454 | | } |
| |
486 | 455 | | |
| |
487 | 456 | | function hasAttributes($products_id) { |
  |
488 | | - | return isset($this->_contents[$products_id]['attributes']) && (empty($this->_contents[$products_id]['attributes']) === false); |
| |
| 457 | + | return isset($this->_contents[$products_id]['attributes']) && !empty($this->_contents[$products_id]['attributes']); |
|
489 | 458 | | } |
| |
490 | 459 | | |
| |
491 | 460 | | function getAttributes($products_id) { |
  |
492 | | - | if (isset($this->_contents[$products_id]['attributes']) && (empty($this->_contents[$products_id]['attributes']) === false)) { |
| |
| 461 | + | if (isset($this->_contents[$products_id]['attributes']) && !empty($this->_contents[$products_id]['attributes'])) { |
|
493 | 462 | | return $this->_contents[$products_id]['attributes']; |
| |
494 | 463 | | } |
| |
495 | 464 | | } |
| |
|
|
 |
… |
|
544 | 513 | | 'suburb' => $Qaddress->valueProtected('entry_suburb'), |
| |
545 | 514 | | 'city' => $Qaddress->valueProtected('entry_city'), |
| |
546 | 515 | | 'postcode' => $Qaddress->valueProtected('entry_postcode'), |
  |
547 | | - | 'state' => (osc_empty($Qaddress->valueProtected('entry_state')) === false) ? $Qaddress->valueProtected('entry_state') : $Qaddress->valueProtected('zone_name'), |
| |
| 516 | + | 'state' => (!osc_empty($Qaddress->valueProtected('entry_state'))) ? $Qaddress->valueProtected('entry_state') : $Qaddress->valueProtected('zone_name'), |
|
548 | 517 | | 'zone_id' => $Qaddress->valueInt('entry_zone_id'), |
| |
549 | 518 | | 'zone_code' => $Qaddress->value('zone_code'), |
| |
550 | 519 | | 'country_id' => $Qaddress->valueInt('entry_country_id'), |
| |
|
|
 |
… |
|
632 | 601 | | 'suburb' => $Qaddress->valueProtected('entry_suburb'), |
| |
633 | 602 | | 'city' => $Qaddress->valueProtected('entry_city'), |
| |
634 | 603 | | 'postcode' => $Qaddress->valueProtected('entry_postcode'), |
  |
635 | | - | 'state' => (osc_empty($Qaddress->valueProtected('entry_state')) === false) ? $Qaddress->valueProtected('entry_state') : $Qaddress->valueProtected('zone_name'), |
| |
| 604 | + | 'state' => (!osc_empty($Qaddress->valueProtected('entry_state'))) ? $Qaddress->valueProtected('entry_state') : $Qaddress->valueProtected('zone_name'), |
|
636 | 605 | | 'zone_id' => $Qaddress->valueInt('entry_zone_id'), |
| |
637 | 606 | | 'zone_code' => $Qaddress->value('zone_code'), |
| |
638 | 607 | | 'country_id' => $Qaddress->valueInt('entry_country_id'), |
| |
|
|
 |
… |
|
734 | 703 | | |
| |
735 | 704 | | // remove from database |
| |
736 | 705 | | if ($osC_Customer->isLoggedOn()) { |
  |
737 | | - | $Qcheck = $osC_Database->query('select customers_basket_attributes_id from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id limit 1'); |
| |
738 | | - | $Qcheck->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
739 | | - | $Qcheck->bindInt(':customers_id', $osC_Customer->getID()); |
| |
740 | | - | $Qcheck->bindValue(':products_id', $products_id); |
| |
741 | | - | $Qcheck->execute(); |
| |
742 | | - | |
| |
743 | | - | if ($Qcheck->numberOfRows() > 0) { |
| |
744 | | - | $Qdelete = $osC_Database->query('delete from :table_customers_basket_attributes where customers_id = :customers_id and products_id = :products_id'); |
| |
745 | | - | $Qdelete->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES); |
| |
746 | | - | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
747 | | - | $Qdelete->bindValue(':products_id', $products_id); |
| |
748 | | - | $Qdelete->execute(); |
| |
749 | | - | } |
| |
750 | | - | |
|
751 | 706 | | $Qdelete = $osC_Database->query('delete from :table_customers_basket where customers_id = :customers_id and products_id = :products_id'); |
| |
752 | 707 | | $Qdelete->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET); |
| |
753 | 708 | | $Qdelete->bindInt(':customers_id', $osC_Customer->getID()); |
| |
|
|
 |
… |
|
811 | 766 | | } |
| |
812 | 767 | | |
| |
813 | 768 | | if ($set_shipping === true) { |
  |
814 | | - | if (class_exists('osC_Shipping') === false) { |
| |
| 769 | + | if (!class_exists('osC_Shipping')) { |
|
815 | 770 | | include('includes/classes/shipping.php'); |
| |
816 | 771 | | } |
| |
817 | 772 | | |
  |
818 | | - | if ( ($this->hasShippingMethod() === false) || ($this->getShippingMethod('is_cheapest') === true) ) { |
| |
| 773 | + | if (!$this->hasShippingMethod() || ($this->getShippingMethod('is_cheapest') === true)) { |
|
819 | 774 | | $osC_Shipping = new osC_Shipping(); |
| |
820 | 775 | | $this->setShippingMethod($osC_Shipping->getCheapestQuote(), false); |
| |
821 | 776 | | } else { |
| |
|
|
 |
… |
|
824 | 779 | | } |
| |
825 | 780 | | } |
| |
826 | 781 | | |
  |
827 | | - | if (class_exists('osC_OrderTotal') === false) { |
| |
| 782 | + | if (!class_exists('osC_OrderTotal')) { |
  |
828 | 783 | | include('includes/classes/order_total.php'); |
| |
829 | 784 | | } |
| |
830 | 785 | | |