| Conditions | 65 |
| Paths | > 20000 |
| Total Lines | 519 |
| Code Lines | 309 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 7 | public function index() |
||
| 8 | { |
||
| 9 | // Validate cart has products and has stock. |
||
| 10 | if (!$this->cart->hasProducts() || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
||
| 11 | $this->response->redirect($this->url->link('checkout/cart')); |
||
| 12 | } |
||
| 13 | |||
| 14 | // scripts & styles |
||
| 15 | $this->document->addStyle('/public_html/assets/css/application/page/checkout/onepagecheckout.css'); |
||
| 16 | // |
||
| 17 | |||
| 18 | // Validate minimum quantity requirements. |
||
| 19 | $products = $this->cart->getProducts(); |
||
| 20 | $this->load->language('checkout/onepagecheckout'); |
||
| 21 | $data['text_login'] = $this->language->get('text_login'); |
||
| 22 | $data['text_notlogged'] = $this->language->get('text_notlogged'); |
||
| 23 | $data['text_customer'] = $this->language->get('text_customer'); |
||
| 24 | $data['text_cart'] = $this->language->get('text_cart'); |
||
| 25 | $data['text_full_name'] = $this->language->get('text_full_name'); |
||
| 26 | $data['text_telephone'] = $this->language->get('text_telephone'); |
||
| 27 | $data['text_email'] = $this->language->get('text_email'); |
||
| 28 | $data['text_town'] = $this->language->get('text_town'); |
||
| 29 | $data['text_delivery_method'] = $this->language->get('text_delivery_method'); |
||
| 30 | $data['text_delivery_type_1'] = $this->language->get('text_delivery_type_1'); |
||
| 31 | $data['text_delivery_type_2'] = $this->language->get('text_delivery_type_2'); |
||
| 32 | $data['text_delivery_placeholder'] = $this->language->get('text_delivery_placeholder'); |
||
| 33 | $data['text_payment_method'] = $this->language->get('text_payment_method'); |
||
| 34 | $data['text_comment'] = $this->language->get('text_comment'); |
||
| 35 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 36 | $data['text_product'] = $this->language->get('text_product'); |
||
| 37 | $data['text_price'] = $this->language->get('text_price'); |
||
| 38 | $data['text_quantity'] = $this->language->get('text_quantity'); |
||
| 39 | $data['text_go_back'] = $this->language->get('text_go_back'); |
||
| 40 | $data['text_total'] = $this->language->get('text_total'); |
||
| 41 | $data['cart_total'] = 0; |
||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | /* login translate*/ |
||
| 47 | |||
| 48 | |||
| 49 | $this->load->language('account/login'); |
||
| 50 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 51 | |||
| 52 | $data['text_new_customer'] = $this->language->get('text_new_customer'); |
||
| 53 | $data['text_register'] = $this->language->get('text_register'); |
||
| 54 | $data['text_register_account'] = $this->language->get('text_register_account'); |
||
| 55 | $data['text_returning_customer'] = $this->language->get('text_returning_customer'); |
||
| 56 | $data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer'); |
||
| 57 | $data['text_forgotten'] = $this->language->get('text_forgotten'); |
||
| 58 | |||
| 59 | $data['entry_email'] = $this->language->get('entry_email'); |
||
| 60 | $data['entry_password'] = $this->language->get('entry_password'); |
||
| 61 | |||
| 62 | $data['button_continue'] = $this->language->get('button_continue'); |
||
| 63 | $data['button_login'] = $this->language->get('button_login'); |
||
| 64 | |||
| 65 | $data['action'] = $this->url->link('account/login', '', true); |
||
| 66 | $data['register'] = $this->url->link('account/register', '', true); |
||
| 67 | $data['forgotten'] = $this->url->link('account/forgotten', '', true); |
||
| 68 | /* if ($this->customer->isLogged()) { |
||
| 69 | $this->response->redirect($this->url->link('account/account', '', true)); |
||
| 70 | }*/ |
||
| 71 | /* login translate END*/ |
||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | foreach ($products as $i => $product) { |
||
| 76 | if (!empty($product['image'])) { |
||
| 77 | $products[$i]['thumb'] = '/public_html/assets/images/' . $product['image']; |
||
| 78 | } else { |
||
| 79 | $products[$i]['thumb'] = '/public_html/assets/images/no_image.png'; |
||
| 80 | } |
||
| 81 | |||
| 82 | if ($this->request->server['REQUEST_METHOD'] != 'POST') { |
||
| 83 | $products[$i]['price'] = $this->currency->format($product['price'], $this->session->data['currency']); |
||
| 84 | } else { |
||
| 85 | $products[$i]['price'] = $product['price']; |
||
| 86 | } |
||
| 87 | $product_total = 0; |
||
| 88 | $data['cart_total'] += $product['total']; |
||
| 89 | $option_data = array(); |
||
| 90 | |||
| 91 | foreach ($product['option'] as $option) { |
||
| 92 | $option_data[] = array( |
||
| 93 | 'product_option_id' => $option['product_option_id'], |
||
| 94 | 'product_option_value_id' => $option['product_option_value_id'], |
||
| 95 | 'option_id' => $option['option_id'], |
||
| 96 | 'option_value_id' => $option['option_value_id'], |
||
| 97 | 'name' => $option['name'], |
||
| 98 | 'value' => $option['value'], |
||
| 99 | 'type' => $option['type'] |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | foreach ($products as $product_2) { |
||
| 103 | if ($product_2['product_id'] == $product['product_id']) { |
||
| 104 | $product_total += $product_2['quantity']; |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | if ($product['minimum'] > $product_total) { |
||
| 109 | $this->response->redirect($this->url->link('checkout/cart')); |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | // Totals |
||
| 114 | $this->load->model('extension/extension'); |
||
| 115 | |||
| 116 | $totals = array(); |
||
| 117 | $total = 0; |
||
| 118 | $total_val = 0; |
||
| 119 | // Because __call can not keep var references so we put them into an array. |
||
| 120 | $total_data = array( |
||
| 121 | 'totals' => &$totals, |
||
| 122 | 'total' => &$total |
||
| 123 | ); |
||
| 124 | |||
| 125 | // Display prices |
||
| 126 | if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { |
||
| 127 | $sort_order = array(); |
||
| 128 | |||
| 129 | $results = $this->model_extension_extension->getExtensions('total'); |
||
| 130 | |||
| 131 | foreach ($results as $key => $value) { |
||
| 132 | $sort_order[$key] = $this->config->get($value['code'] . '_sort_order'); |
||
| 133 | } |
||
| 134 | |||
| 135 | array_multisort($sort_order, SORT_ASC, $results); |
||
| 136 | |||
| 137 | foreach ($results as $result) { |
||
| 138 | if ($this->config->get($result['code'] . '_status')) { |
||
| 139 | $this->load->model('extension/total/' . $result['code']); |
||
| 140 | |||
| 141 | // We have to put the totals in an array so that they pass by reference. |
||
| 142 | $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); |
||
| 143 | } |
||
| 144 | } |
||
| 145 | |||
| 146 | $sort_order = array(); |
||
| 147 | foreach ($totals as $key => $value) { |
||
| 148 | $sort_order[$key] = $value['sort_order']; |
||
| 149 | } |
||
| 150 | |||
| 151 | array_multisort($sort_order, SORT_ASC, $totals); |
||
| 152 | } |
||
| 153 | |||
| 154 | $data['totals'] = array(); |
||
| 155 | foreach ($totals as $total) { |
||
| 156 | $data['totals'][] = array( |
||
| 157 | 'title' => $total['title'], |
||
| 158 | 'text' => $this->currency->format($total['value'], $this->session->data['currency']) |
||
| 159 | ); |
||
| 160 | $total_val += $total['value']; |
||
| 161 | } |
||
| 162 | |||
| 163 | |||
| 164 | $data['products'] = $products; |
||
| 165 | // $total_val = $data['cart_total']; |
||
| 166 | $total_val = $total_data['total']; |
||
| 167 | $data['cart_total'] = $this->currency->format($data['cart_total'], $this->session->data['currency']); |
||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 | $this->load->language('checkout/checkout'); |
||
| 172 | $data['entry_firstname'] = $this->language->get('entry_firstname'); |
||
| 173 | $data['entry_lastname'] = $this->language->get('entry_lastname'); |
||
| 174 | $data['breadcrumbs'] = array(); |
||
| 175 | |||
| 176 | $data['breadcrumbs'][] = array( |
||
| 177 | 'text' => $this->language->get('text_home'), |
||
| 178 | 'href' => $this->url->link('common/home') |
||
| 179 | ); |
||
| 180 | |||
| 181 | $data['breadcrumbs'][] = array( |
||
| 182 | 'text' => $this->language->get('text_cart'), |
||
| 183 | 'href' => $this->url->link('checkout/cart') |
||
| 184 | ); |
||
| 185 | |||
| 186 | $data['breadcrumbs'][] = array( |
||
| 187 | 'text' => $this->language->get('heading_title'), |
||
| 188 | 'href' => $this->url->link('checkout/checkout', '', true) |
||
| 189 | ); |
||
| 190 | |||
| 191 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 192 | |||
| 193 | |||
| 194 | if (isset($this->session->data['error'])) { |
||
| 195 | $data['error_warning'] = $this->session->data['error']; |
||
| 196 | unset($this->session->data['error']); |
||
| 197 | } else { |
||
| 198 | $data['error_warning'] = ''; |
||
| 199 | } |
||
| 200 | |||
| 201 | if ($this->customer->isLogged()) { |
||
| 202 | $this->load->model('account/address'); |
||
| 203 | $addr = $this->model_account_address->getAddress($this->customer->getAddressId()); |
||
| 204 | $data['c_logged'] = true; |
||
| 205 | $data['c_name'] = $this->customer->getFirstName() . ' ' . $this->customer->getLastName(); |
||
| 206 | $data['city'] = $addr['city']; |
||
| 207 | $data['address_1'] = $addr['address_1']; |
||
| 208 | $data['email'] = $this->customer->getEmail(); |
||
| 209 | $data['telephone'] = $this->customer->getTelephone(); |
||
| 210 | } else { |
||
| 211 | $data['c_logged'] = false; |
||
| 212 | $data['c_name'] = ''; |
||
| 213 | $data['city'] = ''; |
||
| 214 | $data['address_1'] = ''; |
||
| 215 | $data['email'] = ''; |
||
| 216 | $data['telephone'] = ''; |
||
| 217 | } |
||
| 218 | |||
| 219 | |||
| 220 | if (isset($this->session->data['account'])) { |
||
| 221 | $data['account'] = $this->session->data['account']; |
||
| 222 | } else { |
||
| 223 | $data['account'] = ''; |
||
| 224 | } |
||
| 225 | if (isset($this->session->data['payment_address']['firstname'])) { |
||
| 226 | $data['firstname'] = $this->session->data['payment_address']['firstname']; |
||
| 227 | } else { |
||
| 228 | $data['firstname'] = ''; |
||
| 229 | } |
||
| 230 | |||
| 231 | |||
| 232 | if (isset($this->session->data['payment_address']['address_1'])) { |
||
| 233 | $data['address_1'] = $this->session->data['payment_address']['address_1']; //nomer otdelenia ili adres poluchatelya |
||
| 234 | } |
||
| 235 | |||
| 236 | if (isset($this->session->data['payment_address']['city'])) { |
||
| 237 | $data['city'] = $this->session->data['payment_address']['city']; |
||
| 238 | } |
||
| 239 | if (isset($this->session->data['payment_address']['telephone'])) { |
||
| 240 | $data['telephone'] = $this->session->data['payment_address']['telephone']; |
||
| 241 | } |
||
| 242 | if (isset($this->session->data['comment'])) { |
||
| 243 | $data['comment'] = $this->session->data['comment']; |
||
| 244 | } else { |
||
| 245 | $data['comment'] = ''; |
||
| 246 | } |
||
| 247 | if (isset($this->session->data['email'])) { |
||
| 248 | $data['email'] = $this->session->data['email']; |
||
| 249 | } |
||
| 250 | |||
| 251 | if (isset($this->session->data['address_1'])) { |
||
| 252 | $data['address_1'] = $this->session->data['address_1']; |
||
| 253 | } |
||
| 254 | |||
| 255 | |||
| 256 | // var_dump(json_decode('{"type": "page", "id": 1, "color": "#69F"}',true));exit; |
||
| 257 | $this->errors = []; |
||
| 258 | if (($this->request->server['REQUEST_METHOD'] == 'POST')) { |
||
| 259 | if ($this->validate_form()) { |
||
| 260 | $order_data = array(); |
||
| 261 | if ($this->affiliate->isLogged()) { |
||
| 262 | $order_data['affiliate_id'] = $this->affiliate->getId(); |
||
| 263 | } else { |
||
| 264 | $order_data['affiliate_id'] = ''; |
||
| 265 | } |
||
| 266 | $order_data['invoice_prefix'] = $this->config->get('config_invoice_prefix'); |
||
| 267 | $order_data['store_name'] = $this->config->get('config_name'); |
||
| 268 | $order_data['store_url'] = '/'; |
||
| 269 | $order_data['products'] = $data['products']; |
||
| 270 | $order_data['cart_total'] = $total_val; |
||
| 271 | if (isset($this->request->post['firstname'])) { |
||
| 272 | $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; |
||
| 273 | $order_data['firstname'] = $this->request->post['firstname']; |
||
| 274 | } |
||
| 275 | if (isset($this->request->post['telephone'])) { |
||
| 276 | $this->session->data['payment_address']['telephone'] = $this->request->post['telephone']; |
||
| 277 | $order_data['telephone'] = $this->request->post['telephone']; |
||
| 278 | } |
||
| 279 | if (isset($this->request->post['email'])) { |
||
| 280 | $this->session->data['payment_address']['email'] = $this->request->post['email']; |
||
| 281 | $order_data['email'] = $this->request->post['email']; |
||
| 282 | if (!empty(trim($this->request->post['email']))) { |
||
| 283 | $order_data['order_status_id'] = 0; |
||
| 284 | } else { |
||
| 285 | $order_data['order_status_id'] = $this->config->get('config_order_status_id'); |
||
| 286 | } |
||
| 287 | } |
||
| 288 | if (isset($this->request->post['city'])) { |
||
| 289 | $this->session->data['payment_address']['city'] = $this->request->post['city']; |
||
| 290 | $order_data['city'] = $this->request->post['city']; |
||
| 291 | } |
||
| 292 | |||
| 293 | if (isset($this->request->post['shipping_method'])) { |
||
| 294 | $this->session->data['shipping_method'] = json_decode(htmlspecialchars_decode($this->request->post['shipping_method']), true); |
||
| 295 | $order_data['shipping_method'] = json_decode(htmlspecialchars_decode($this->request->post['shipping_method']), true); |
||
| 296 | } |
||
| 297 | |||
| 298 | //var_dump( $order_data); exit; |
||
| 299 | |||
| 300 | if (isset($this->request->post['address_1'])) { |
||
| 301 | $this->session->data['payment_address']['address_1'] = $this->request->post['address_1']; |
||
| 302 | $order_data['address_1'] = $this->request->post['address_1']; |
||
| 303 | } |
||
| 304 | // var_dump( json_encode(['title'=>'title','val'=>'val']));exit; |
||
| 305 | |||
| 306 | |||
| 307 | if (isset($this->request->post['payment_method'])) { |
||
| 308 | $this->session->data['payment_method'] = json_decode(htmlspecialchars_decode($this->request->post['payment_method']), true); |
||
| 309 | $order_data['payment_method'] = json_decode(htmlspecialchars_decode($this->request->post['payment_method']), true); |
||
| 310 | } |
||
| 311 | |||
| 312 | if (isset($this->request->post['firstname'])) { |
||
| 313 | $this->session->data['firstname'] = $this->request->post['firstname']; |
||
| 314 | } |
||
| 315 | |||
| 316 | if (isset($this->request->post['comment'])) { |
||
| 317 | $this->session->data['comment'] = $this->request->post['comment']; |
||
| 318 | $order_data['comment'] = $this->request->post['comment']; |
||
| 319 | } |
||
| 320 | if (isset($this->request->post['delivery-type'])) { |
||
| 321 | $this->session->data['delivery-type'] = $this->request->post['delivery-type']; |
||
| 322 | $order_data['address_1'] = $this->request->post['delivery-type'] . ' - ' . $order_data['address_1']; |
||
| 323 | } |
||
| 324 | |||
| 325 | |||
| 326 | $order_data['language_id'] = $this->config->get('config_language_id'); |
||
| 327 | $order_data['currency_id'] = $this->currency->getId($this->session->data['currency']); |
||
| 328 | $order_data['currency_code'] = $this->session->data['currency']; |
||
| 329 | $order_data['currency_value'] = $this->currency->getValue($this->session->data['currency']); |
||
| 330 | $order_data['ip'] = $this->request->server['REMOTE_ADDR']; |
||
| 331 | |||
| 332 | if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) { |
||
| 333 | $order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR']; |
||
| 334 | } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) { |
||
| 335 | $order_data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP']; |
||
| 336 | } else { |
||
| 337 | $order_data['forwarded_ip'] = ''; |
||
| 338 | } |
||
| 339 | |||
| 340 | if (isset($this->request->server['HTTP_USER_AGENT'])) { |
||
| 341 | $order_data['user_agent'] = $this->request->server['HTTP_USER_AGENT']; |
||
| 342 | } else { |
||
| 343 | $order_data['user_agent'] = ''; |
||
| 344 | } |
||
| 345 | |||
| 346 | if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { |
||
| 347 | $order_data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE']; |
||
| 348 | } else { |
||
| 349 | $order_data['accept_language'] = ''; |
||
| 350 | } |
||
| 351 | |||
| 352 | |||
| 353 | |||
| 354 | |||
| 355 | $order_data['customer_id'] = 0; |
||
| 356 | if (isset($this->session->data['guest']['customer_group_id'])) { |
||
| 357 | $order_data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; |
||
| 358 | } else { |
||
| 359 | $order_data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
||
| 360 | } |
||
| 361 | |||
| 362 | |||
| 363 | $this->load->model('checkout/onepagecheckout'); |
||
| 364 | $json['order_id'] = $this->model_checkout_onepagecheckout->addOrder($order_data); |
||
| 365 | $this->load->model('checkout/order'); |
||
| 366 | $this->model_checkout_order->addOrderHistory($json['order_id'], $this->config->get('config_order_status_id'), '', 0, 0); |
||
| 367 | |||
| 368 | $this->session->data['order_id'] = $json['order_id']; |
||
| 369 | // $json['order_id']=$this->addOrder($order_data); |
||
| 370 | // var_dump($this->session->data['payment_method']);exit; |
||
| 371 | |||
| 372 | $json['payment'] = $this->load->controller('extension/payment/' . $this->session->data['payment_method']['code']); |
||
| 373 | if ($this->session->data['payment_method']['code'] == 'cod') { |
||
| 374 | $json['cod'] = 1; |
||
| 375 | } |
||
| 376 | } else { |
||
| 377 | $json['error'] = $this->errors; |
||
| 378 | } |
||
| 379 | |||
| 380 | $this->response->addHeader('Content-Type: application/json'); |
||
| 381 | $this->response->setOutput(json_encode($json)); |
||
| 382 | } else { |
||
| 383 | $this->session->data['shipping_address']['country_id'] = 0; |
||
| 384 | $this->session->data['shipping_address']['zone_id'] = 0; |
||
| 385 | /*get shippings methods*/ |
||
| 386 | |||
| 387 | |||
| 388 | // Shipping Methods |
||
| 389 | $method_data = array(); |
||
| 390 | |||
| 391 | $this->load->model('extension/extension'); |
||
| 392 | |||
| 393 | $results = $this->model_extension_extension->getExtensions('shipping'); |
||
| 394 | |||
| 395 | foreach ($results as $result) { |
||
| 396 | if ($this->config->get($result['code'] . '_status')) { |
||
| 397 | $this->load->model('extension/shipping/' . $result['code']); |
||
| 398 | |||
| 399 | $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); |
||
| 400 | |||
| 401 | if ($quote) { |
||
| 402 | $method_data[$result['code']] = array( |
||
| 403 | 'title' => $quote['title'], |
||
| 404 | 'quote' => $quote['quote'], |
||
| 405 | 'sort_order' => $quote['sort_order'], |
||
| 406 | 'error' => $quote['error'] |
||
| 407 | ); |
||
| 408 | } |
||
| 409 | } |
||
| 410 | } |
||
| 411 | |||
| 412 | $sort_order = array(); |
||
| 413 | |||
| 414 | foreach ($method_data as $key => $value) { |
||
| 415 | $sort_order[$key] = $value['sort_order']; |
||
| 416 | } |
||
| 417 | |||
| 418 | array_multisort($sort_order, SORT_ASC, $method_data); |
||
| 419 | |||
| 420 | $this->session->data['shipping_methods'] = $method_data; |
||
| 421 | |||
| 422 | |||
| 423 | foreach ($method_data as $i => $shipping_method) { |
||
| 424 | foreach ($shipping_method['quote'] as $shipping_method2) { |
||
| 425 | $data['shippig_methods'][$i]['value'] = $shipping_method2['code']; |
||
| 426 | $data['shippig_methods'][$i]['title'] = $shipping_method2['title']; |
||
| 427 | if (isset($shipping_method2['cost'])) { |
||
| 428 | $data['shippig_methods'][$i]['cost'] = $shipping_method2['cost']; |
||
| 429 | } else { |
||
| 430 | $data['shippig_methods'][$i]['cost'] = ''; |
||
| 431 | } |
||
| 432 | } |
||
| 433 | } |
||
| 434 | //var_dump( $data['shippig_methods']);exit; |
||
| 435 | |||
| 436 | |||
| 437 | /* payment methods*/ |
||
| 438 | // Payment Methods |
||
| 439 | // Totals |
||
| 440 | $totals = array(); |
||
| 441 | $total = 0; |
||
| 442 | |||
| 443 | // Because __call can not keep var references so we put them into an array. |
||
| 444 | $total_data = array( |
||
| 445 | 'totals' => &$totals, |
||
| 446 | 'total' => &$total |
||
| 447 | ); |
||
| 448 | |||
| 449 | $this->load->model('extension/extension'); |
||
| 450 | |||
| 451 | $sort_order = array(); |
||
| 452 | |||
| 453 | $results = $this->model_extension_extension->getExtensions('total'); |
||
| 454 | |||
| 455 | foreach ($results as $key => $value) { |
||
| 456 | $sort_order[$key] = $this->config->get($value['code'] . '_sort_order'); |
||
| 457 | } |
||
| 458 | |||
| 459 | array_multisort($sort_order, SORT_ASC, $results); |
||
| 460 | |||
| 461 | foreach ($results as $result) { |
||
| 462 | if ($this->config->get($result['code'] . '_status')) { |
||
| 463 | $this->load->model('extension/total/' . $result['code']); |
||
| 464 | |||
| 465 | // We have to put the totals in an array so that they pass by reference. |
||
| 466 | $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); |
||
| 467 | } |
||
| 468 | } |
||
| 469 | |||
| 470 | |||
| 471 | $data['modules'] = array(); |
||
| 472 | |||
| 473 | $files = glob(SR_APPLICATION . '/controller/extension/total/*.php'); |
||
| 474 | |||
| 475 | if ($files) { |
||
| 476 | foreach ($files as $file) { |
||
| 477 | $result = $this->load->controller('extension/total/' . basename($file, '.php')); |
||
| 478 | |||
| 479 | if ($result) { |
||
| 480 | $data['modules'][] = $result; |
||
| 481 | } |
||
| 482 | } |
||
| 483 | } |
||
| 484 | |||
| 485 | |||
| 486 | $method_data = array(); |
||
| 487 | $this->session->data['payment_address']['country_id'] = 0; |
||
| 488 | $this->session->data['payment_address']['zone_id'] = 0; |
||
| 489 | $this->load->model('extension/extension'); |
||
| 490 | |||
| 491 | $results = $this->model_extension_extension->getExtensions('payment'); |
||
| 492 | |||
| 493 | foreach ($results as $result) { |
||
| 494 | if ($this->config->get($result['code'] . '_status')) { |
||
| 495 | $this->load->model('extension/payment/' . $result['code']); |
||
| 496 | |||
| 497 | $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total); |
||
| 498 | |||
| 499 | if ($method) { |
||
| 500 | $method_data[$result['code']] = $method; |
||
| 501 | } |
||
| 502 | } |
||
| 503 | } |
||
| 504 | |||
| 505 | $sort_order = array(); |
||
| 506 | |||
| 507 | foreach ($method_data as $key => $value) { |
||
| 508 | $sort_order[$key] = $value['sort_order']; |
||
| 509 | } |
||
| 510 | |||
| 511 | array_multisort($sort_order, SORT_ASC, $method_data); |
||
| 512 | |||
| 513 | |||
| 514 | $this->session->data['payment_methods'] = $method_data; |
||
| 515 | |||
| 516 | |||
| 517 | $data['payment_methods'] = $method_data; |
||
| 518 | |||
| 519 | |||
| 520 | $data['content_top'] = $this->load->controller('common/content_top'); |
||
| 521 | $data['content_bottom'] = $this->load->controller('common/content_bottom'); |
||
| 522 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 523 | $data['header'] = $this->load->controller('common/header'); |
||
| 524 | |||
| 525 | $this->response->setOutput($this->load->view('checkout/onepagecheckout', $data)); |
||
| 526 | } |
||
| 672 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.