PageRenderTime 53ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/upload/admin/controller/sale/order.php

https://github.com/kstep/opencart
PHP | 2530 lines | 1998 code | 527 blank | 5 comment | 462 complexity | b82d310c365a840981cfdc5c697c084f MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class ControllerSaleOrder extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->language->load('sale/order');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('sale/order');
  8. $this->getList();
  9. }
  10. public function insert() {
  11. $this->language->load('sale/order');
  12. $this->document->setTitle($this->language->get('heading_title'));
  13. $this->load->model('sale/order');
  14. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  15. $this->model_sale_order->addOrder($this->request->post);
  16. $this->session->data['success'] = $this->language->get('text_success');
  17. $url = '';
  18. if (isset($this->request->get['filter_order_id'])) {
  19. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  20. }
  21. if (isset($this->request->get['filter_customer'])) {
  22. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  23. }
  24. if (isset($this->request->get['filter_order_status_id'])) {
  25. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  26. }
  27. if (isset($this->request->get['filter_total'])) {
  28. $url .= '&filter_total=' . $this->request->get['filter_total'];
  29. }
  30. if (isset($this->request->get['filter_date_added'])) {
  31. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  32. }
  33. if (isset($this->request->get['filter_date_modified'])) {
  34. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  35. }
  36. if (isset($this->request->get['sort'])) {
  37. $url .= '&sort=' . $this->request->get['sort'];
  38. }
  39. if (isset($this->request->get['order'])) {
  40. $url .= '&order=' . $this->request->get['order'];
  41. }
  42. if (isset($this->request->get['page'])) {
  43. $url .= '&page=' . $this->request->get['page'];
  44. }
  45. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  46. }
  47. $this->getForm();
  48. }
  49. public function update() {
  50. $this->language->load('sale/order');
  51. $this->document->setTitle($this->language->get('heading_title'));
  52. $this->load->model('sale/order');
  53. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
  54. $this->model_sale_order->editOrder($this->request->get['order_id'], $this->request->post);
  55. $this->session->data['success'] = $this->language->get('text_success');
  56. $url = '';
  57. if (isset($this->request->get['filter_order_id'])) {
  58. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  59. }
  60. if (isset($this->request->get['filter_customer'])) {
  61. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  62. }
  63. if (isset($this->request->get['filter_order_status_id'])) {
  64. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  65. }
  66. if (isset($this->request->get['filter_total'])) {
  67. $url .= '&filter_total=' . $this->request->get['filter_total'];
  68. }
  69. if (isset($this->request->get['filter_date_added'])) {
  70. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  71. }
  72. if (isset($this->request->get['filter_date_modified'])) {
  73. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  74. }
  75. if (isset($this->request->get['sort'])) {
  76. $url .= '&sort=' . $this->request->get['sort'];
  77. }
  78. if (isset($this->request->get['order'])) {
  79. $url .= '&order=' . $this->request->get['order'];
  80. }
  81. if (isset($this->request->get['page'])) {
  82. $url .= '&page=' . $this->request->get['page'];
  83. }
  84. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  85. }
  86. $this->getForm();
  87. }
  88. public function delete() {
  89. $this->language->load('sale/order');
  90. $this->document->setTitle($this->language->get('heading_title'));
  91. $this->load->model('sale/order');
  92. if (isset($this->request->post['selected']) && ($this->validateDelete())) {
  93. foreach ($this->request->post['selected'] as $order_id) {
  94. $this->model_sale_order->deleteOrder($order_id);
  95. }
  96. $this->session->data['success'] = $this->language->get('text_success');
  97. $url = '';
  98. if (isset($this->request->get['filter_order_id'])) {
  99. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  100. }
  101. if (isset($this->request->get['filter_customer'])) {
  102. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  103. }
  104. if (isset($this->request->get['filter_order_status_id'])) {
  105. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  106. }
  107. if (isset($this->request->get['filter_total'])) {
  108. $url .= '&filter_total=' . $this->request->get['filter_total'];
  109. }
  110. if (isset($this->request->get['filter_date_added'])) {
  111. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  112. }
  113. if (isset($this->request->get['filter_date_modified'])) {
  114. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  115. }
  116. if (isset($this->request->get['sort'])) {
  117. $url .= '&sort=' . $this->request->get['sort'];
  118. }
  119. if (isset($this->request->get['order'])) {
  120. $url .= '&order=' . $this->request->get['order'];
  121. }
  122. if (isset($this->request->get['page'])) {
  123. $url .= '&page=' . $this->request->get['page'];
  124. }
  125. $this->redirect($this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'));
  126. }
  127. $this->getList();
  128. }
  129. protected function getList() {
  130. if (isset($this->request->get['filter_order_id'])) {
  131. $filter_order_id = $this->request->get['filter_order_id'];
  132. } else {
  133. $filter_order_id = null;
  134. }
  135. if (isset($this->request->get['filter_customer'])) {
  136. $filter_customer = $this->request->get['filter_customer'];
  137. } else {
  138. $filter_customer = null;
  139. }
  140. if (isset($this->request->get['filter_order_status_id'])) {
  141. $filter_order_status_id = $this->request->get['filter_order_status_id'];
  142. } else {
  143. $filter_order_status_id = null;
  144. }
  145. if (isset($this->request->get['filter_total'])) {
  146. $filter_total = $this->request->get['filter_total'];
  147. } else {
  148. $filter_total = null;
  149. }
  150. if (isset($this->request->get['filter_date_added'])) {
  151. $filter_date_added = $this->request->get['filter_date_added'];
  152. } else {
  153. $filter_date_added = null;
  154. }
  155. if (isset($this->request->get['filter_date_modified'])) {
  156. $filter_date_modified = $this->request->get['filter_date_modified'];
  157. } else {
  158. $filter_date_modified = null;
  159. }
  160. if (isset($this->request->get['sort'])) {
  161. $sort = $this->request->get['sort'];
  162. } else {
  163. $sort = 'o.order_id';
  164. }
  165. if (isset($this->request->get['order'])) {
  166. $order = $this->request->get['order'];
  167. } else {
  168. $order = 'DESC';
  169. }
  170. if (isset($this->request->get['page'])) {
  171. $page = $this->request->get['page'];
  172. } else {
  173. $page = 1;
  174. }
  175. $url = '';
  176. if (isset($this->request->get['filter_order_id'])) {
  177. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  178. }
  179. if (isset($this->request->get['filter_customer'])) {
  180. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  181. }
  182. if (isset($this->request->get['filter_order_status_id'])) {
  183. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  184. }
  185. if (isset($this->request->get['filter_total'])) {
  186. $url .= '&filter_total=' . $this->request->get['filter_total'];
  187. }
  188. if (isset($this->request->get['filter_date_added'])) {
  189. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  190. }
  191. if (isset($this->request->get['filter_date_modified'])) {
  192. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  193. }
  194. if (isset($this->request->get['sort'])) {
  195. $url .= '&sort=' . $this->request->get['sort'];
  196. }
  197. if (isset($this->request->get['order'])) {
  198. $url .= '&order=' . $this->request->get['order'];
  199. }
  200. if (isset($this->request->get['page'])) {
  201. $url .= '&page=' . $this->request->get['page'];
  202. }
  203. $this->data['breadcrumbs'] = array();
  204. $this->data['breadcrumbs'][] = array(
  205. 'text' => $this->language->get('text_home'),
  206. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  207. 'separator' => false
  208. );
  209. $this->data['breadcrumbs'][] = array(
  210. 'text' => $this->language->get('heading_title'),
  211. 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'),
  212. 'separator' => ' :: '
  213. );
  214. $this->data['invoice'] = $this->url->link('sale/order/invoice', 'token=' . $this->session->data['token'], 'SSL');
  215. $this->data['insert'] = $this->url->link('sale/order/insert', 'token=' . $this->session->data['token'], 'SSL');
  216. $this->data['delete'] = $this->url->link('sale/order/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
  217. $this->data['orders'] = array();
  218. $data = array(
  219. 'filter_order_id' => $filter_order_id,
  220. 'filter_customer' => $filter_customer,
  221. 'filter_order_status_id' => $filter_order_status_id,
  222. 'filter_total' => $filter_total,
  223. 'filter_date_added' => $filter_date_added,
  224. 'filter_date_modified' => $filter_date_modified,
  225. 'sort' => $sort,
  226. 'order' => $order,
  227. 'start' => ($page - 1) * $this->config->get('config_admin_limit'),
  228. 'limit' => $this->config->get('config_admin_limit')
  229. );
  230. $order_total = $this->model_sale_order->getTotalOrders($data);
  231. $results = $this->model_sale_order->getOrders($data);
  232. foreach ($results as $result) {
  233. $action = array();
  234. $action[] = array(
  235. 'text' => $this->language->get('text_view'),
  236. 'href' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, 'SSL')
  237. );
  238. if (strtotime($result['date_added']) > strtotime('-' . (int)$this->config->get('config_order_edit') . ' day')) {
  239. $action[] = array(
  240. 'text' => $this->language->get('text_edit'),
  241. 'href' => $this->url->link('sale/order/update', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . $url, 'SSL')
  242. );
  243. }
  244. $this->data['orders'][] = array(
  245. 'order_id' => $result['order_id'],
  246. 'customer' => $result['customer'],
  247. 'status' => $result['status'],
  248. 'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
  249. 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
  250. 'date_modified' => date($this->language->get('date_format_short'), strtotime($result['date_modified'])),
  251. 'selected' => isset($this->request->post['selected']) && in_array($result['order_id'], $this->request->post['selected']),
  252. 'action' => $action
  253. );
  254. }
  255. $this->data['heading_title'] = $this->language->get('heading_title');
  256. $this->data['text_no_results'] = $this->language->get('text_no_results');
  257. $this->data['text_missing'] = $this->language->get('text_missing');
  258. $this->data['column_order_id'] = $this->language->get('column_order_id');
  259. $this->data['column_customer'] = $this->language->get('column_customer');
  260. $this->data['column_status'] = $this->language->get('column_status');
  261. $this->data['column_total'] = $this->language->get('column_total');
  262. $this->data['column_date_added'] = $this->language->get('column_date_added');
  263. $this->data['column_date_modified'] = $this->language->get('column_date_modified');
  264. $this->data['column_action'] = $this->language->get('column_action');
  265. $this->data['button_invoice'] = $this->language->get('button_invoice');
  266. $this->data['button_insert'] = $this->language->get('button_insert');
  267. $this->data['button_delete'] = $this->language->get('button_delete');
  268. $this->data['button_filter'] = $this->language->get('button_filter');
  269. $this->data['token'] = $this->session->data['token'];
  270. if (isset($this->error['warning'])) {
  271. $this->data['error_warning'] = $this->error['warning'];
  272. } else {
  273. $this->data['error_warning'] = '';
  274. }
  275. if (isset($this->session->data['success'])) {
  276. $this->data['success'] = $this->session->data['success'];
  277. unset($this->session->data['success']);
  278. } else {
  279. $this->data['success'] = '';
  280. }
  281. $url = '';
  282. if (isset($this->request->get['filter_order_id'])) {
  283. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  284. }
  285. if (isset($this->request->get['filter_customer'])) {
  286. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  287. }
  288. if (isset($this->request->get['filter_order_status_id'])) {
  289. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  290. }
  291. if (isset($this->request->get['filter_total'])) {
  292. $url .= '&filter_total=' . $this->request->get['filter_total'];
  293. }
  294. if (isset($this->request->get['filter_date_added'])) {
  295. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  296. }
  297. if (isset($this->request->get['filter_date_modified'])) {
  298. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  299. }
  300. if ($order == 'ASC') {
  301. $url .= '&order=DESC';
  302. } else {
  303. $url .= '&order=ASC';
  304. }
  305. if (isset($this->request->get['page'])) {
  306. $url .= '&page=' . $this->request->get['page'];
  307. }
  308. $this->data['sort_order'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.order_id' . $url, 'SSL');
  309. $this->data['sort_customer'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=customer' . $url, 'SSL');
  310. $this->data['sort_status'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=status' . $url, 'SSL');
  311. $this->data['sort_total'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.total' . $url, 'SSL');
  312. $this->data['sort_date_added'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_added' . $url, 'SSL');
  313. $this->data['sort_date_modified'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . '&sort=o.date_modified' . $url, 'SSL');
  314. $url = '';
  315. if (isset($this->request->get['filter_order_id'])) {
  316. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  317. }
  318. if (isset($this->request->get['filter_customer'])) {
  319. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  320. }
  321. if (isset($this->request->get['filter_order_status_id'])) {
  322. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  323. }
  324. if (isset($this->request->get['filter_total'])) {
  325. $url .= '&filter_total=' . $this->request->get['filter_total'];
  326. }
  327. if (isset($this->request->get['filter_date_added'])) {
  328. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  329. }
  330. if (isset($this->request->get['filter_date_modified'])) {
  331. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  332. }
  333. if (isset($this->request->get['sort'])) {
  334. $url .= '&sort=' . $this->request->get['sort'];
  335. }
  336. if (isset($this->request->get['order'])) {
  337. $url .= '&order=' . $this->request->get['order'];
  338. }
  339. $pagination = new Pagination();
  340. $pagination->total = $order_total;
  341. $pagination->page = $page;
  342. $pagination->limit = $this->config->get('config_admin_limit');
  343. $pagination->text = $this->language->get('text_pagination');
  344. $pagination->url = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  345. $this->data['pagination'] = $pagination->render();
  346. $this->data['filter_order_id'] = $filter_order_id;
  347. $this->data['filter_customer'] = $filter_customer;
  348. $this->data['filter_order_status_id'] = $filter_order_status_id;
  349. $this->data['filter_total'] = $filter_total;
  350. $this->data['filter_date_added'] = $filter_date_added;
  351. $this->data['filter_date_modified'] = $filter_date_modified;
  352. $this->load->model('localisation/order_status');
  353. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  354. $this->data['sort'] = $sort;
  355. $this->data['order'] = $order;
  356. $this->template = 'sale/order_list.tpl';
  357. $this->children = array(
  358. 'common/header',
  359. 'common/footer'
  360. );
  361. $this->response->setOutput($this->render());
  362. }
  363. public function getForm() {
  364. $this->load->model('sale/customer');
  365. $this->data['heading_title'] = $this->language->get('heading_title');
  366. $this->data['text_no_results'] = $this->language->get('text_no_results');
  367. $this->data['text_default'] = $this->language->get('text_default');
  368. $this->data['text_select'] = $this->language->get('text_select');
  369. $this->data['text_none'] = $this->language->get('text_none');
  370. $this->data['text_wait'] = $this->language->get('text_wait');
  371. $this->data['text_product'] = $this->language->get('text_product');
  372. $this->data['text_voucher'] = $this->language->get('text_voucher');
  373. $this->data['text_order'] = $this->language->get('text_order');
  374. $this->data['entry_store'] = $this->language->get('entry_store');
  375. $this->data['entry_customer'] = $this->language->get('entry_customer');
  376. $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
  377. $this->data['entry_firstname'] = $this->language->get('entry_firstname');
  378. $this->data['entry_lastname'] = $this->language->get('entry_lastname');
  379. $this->data['entry_email'] = $this->language->get('entry_email');
  380. $this->data['entry_telephone'] = $this->language->get('entry_telephone');
  381. $this->data['entry_fax'] = $this->language->get('entry_fax');
  382. $this->data['entry_order_status'] = $this->language->get('entry_order_status');
  383. $this->data['entry_comment'] = $this->language->get('entry_comment');
  384. $this->data['entry_affiliate'] = $this->language->get('entry_affiliate');
  385. $this->data['entry_address'] = $this->language->get('entry_address');
  386. $this->data['entry_company'] = $this->language->get('entry_company');
  387. $this->data['entry_address_1'] = $this->language->get('entry_address_1');
  388. $this->data['entry_address_2'] = $this->language->get('entry_address_2');
  389. $this->data['entry_city'] = $this->language->get('entry_city');
  390. $this->data['entry_postcode'] = $this->language->get('entry_postcode');
  391. $this->data['entry_zone'] = $this->language->get('entry_zone');
  392. $this->data['entry_zone_code'] = $this->language->get('entry_zone_code');
  393. $this->data['entry_country'] = $this->language->get('entry_country');
  394. $this->data['entry_product'] = $this->language->get('entry_product');
  395. $this->data['entry_option'] = $this->language->get('entry_option');
  396. $this->data['entry_quantity'] = $this->language->get('entry_quantity');
  397. $this->data['entry_to_name'] = $this->language->get('entry_to_name');
  398. $this->data['entry_to_email'] = $this->language->get('entry_to_email');
  399. $this->data['entry_from_name'] = $this->language->get('entry_from_name');
  400. $this->data['entry_from_email'] = $this->language->get('entry_from_email');
  401. $this->data['entry_theme'] = $this->language->get('entry_theme');
  402. $this->data['entry_message'] = $this->language->get('entry_message');
  403. $this->data['entry_amount'] = $this->language->get('entry_amount');
  404. $this->data['entry_shipping'] = $this->language->get('entry_shipping');
  405. $this->data['entry_payment'] = $this->language->get('entry_payment');
  406. $this->data['entry_voucher'] = $this->language->get('entry_voucher');
  407. $this->data['entry_coupon'] = $this->language->get('entry_coupon');
  408. $this->data['entry_reward'] = $this->language->get('entry_reward');
  409. $this->data['column_product'] = $this->language->get('column_product');
  410. $this->data['column_model'] = $this->language->get('column_model');
  411. $this->data['column_quantity'] = $this->language->get('column_quantity');
  412. $this->data['column_price'] = $this->language->get('column_price');
  413. $this->data['column_total'] = $this->language->get('column_total');
  414. $this->data['button_save'] = $this->language->get('button_save');
  415. $this->data['button_cancel'] = $this->language->get('button_cancel');
  416. $this->data['button_add_product'] = $this->language->get('button_add_product');
  417. $this->data['button_add_voucher'] = $this->language->get('button_add_voucher');
  418. $this->data['button_update_total'] = $this->language->get('button_update_total');
  419. $this->data['button_remove'] = $this->language->get('button_remove');
  420. $this->data['button_upload'] = $this->language->get('button_upload');
  421. $this->data['tab_order'] = $this->language->get('tab_order');
  422. $this->data['tab_customer'] = $this->language->get('tab_customer');
  423. $this->data['tab_payment'] = $this->language->get('tab_payment');
  424. $this->data['tab_shipping'] = $this->language->get('tab_shipping');
  425. $this->data['tab_product'] = $this->language->get('tab_product');
  426. $this->data['tab_voucher'] = $this->language->get('tab_voucher');
  427. $this->data['tab_total'] = $this->language->get('tab_total');
  428. if (isset($this->error['warning'])) {
  429. $this->data['error_warning'] = $this->error['warning'];
  430. } else {
  431. $this->data['error_warning'] = '';
  432. }
  433. if (isset($this->error['firstname'])) {
  434. $this->data['error_firstname'] = $this->error['firstname'];
  435. } else {
  436. $this->data['error_firstname'] = '';
  437. }
  438. if (isset($this->error['lastname'])) {
  439. $this->data['error_lastname'] = $this->error['lastname'];
  440. } else {
  441. $this->data['error_lastname'] = '';
  442. }
  443. if (isset($this->error['email'])) {
  444. $this->data['error_email'] = $this->error['email'];
  445. } else {
  446. $this->data['error_email'] = '';
  447. }
  448. if (isset($this->error['telephone'])) {
  449. $this->data['error_telephone'] = $this->error['telephone'];
  450. } else {
  451. $this->data['error_telephone'] = '';
  452. }
  453. if (isset($this->error['payment_firstname'])) {
  454. $this->data['error_payment_firstname'] = $this->error['payment_firstname'];
  455. } else {
  456. $this->data['error_payment_firstname'] = '';
  457. }
  458. if (isset($this->error['payment_lastname'])) {
  459. $this->data['error_payment_lastname'] = $this->error['payment_lastname'];
  460. } else {
  461. $this->data['error_payment_lastname'] = '';
  462. }
  463. if (isset($this->error['payment_address_1'])) {
  464. $this->data['error_payment_address_1'] = $this->error['payment_address_1'];
  465. } else {
  466. $this->data['error_payment_address_1'] = '';
  467. }
  468. if (isset($this->error['payment_city'])) {
  469. $this->data['error_payment_city'] = $this->error['payment_city'];
  470. } else {
  471. $this->data['error_payment_city'] = '';
  472. }
  473. if (isset($this->error['payment_postcode'])) {
  474. $this->data['error_payment_postcode'] = $this->error['payment_postcode'];
  475. } else {
  476. $this->data['error_payment_postcode'] = '';
  477. }
  478. if (isset($this->error['payment_tax_id'])) {
  479. $this->data['error_payment_tax_id'] = $this->error['payment_tax_id'];
  480. } else {
  481. $this->data['error_payment_tax_id'] = '';
  482. }
  483. if (isset($this->error['payment_country'])) {
  484. $this->data['error_payment_country'] = $this->error['payment_country'];
  485. } else {
  486. $this->data['error_payment_country'] = '';
  487. }
  488. if (isset($this->error['payment_zone'])) {
  489. $this->data['error_payment_zone'] = $this->error['payment_zone'];
  490. } else {
  491. $this->data['error_payment_zone'] = '';
  492. }
  493. if (isset($this->error['payment_method'])) {
  494. $this->data['error_payment_method'] = $this->error['payment_method'];
  495. } else {
  496. $this->data['error_payment_method'] = '';
  497. }
  498. if (isset($this->error['shipping_firstname'])) {
  499. $this->data['error_shipping_firstname'] = $this->error['shipping_firstname'];
  500. } else {
  501. $this->data['error_shipping_firstname'] = '';
  502. }
  503. if (isset($this->error['shipping_lastname'])) {
  504. $this->data['error_shipping_lastname'] = $this->error['shipping_lastname'];
  505. } else {
  506. $this->data['error_shipping_lastname'] = '';
  507. }
  508. if (isset($this->error['shipping_address_1'])) {
  509. $this->data['error_shipping_address_1'] = $this->error['shipping_address_1'];
  510. } else {
  511. $this->data['error_shipping_address_1'] = '';
  512. }
  513. if (isset($this->error['shipping_city'])) {
  514. $this->data['error_shipping_city'] = $this->error['shipping_city'];
  515. } else {
  516. $this->data['error_shipping_city'] = '';
  517. }
  518. if (isset($this->error['shipping_postcode'])) {
  519. $this->data['error_shipping_postcode'] = $this->error['shipping_postcode'];
  520. } else {
  521. $this->data['error_shipping_postcode'] = '';
  522. }
  523. if (isset($this->error['shipping_country'])) {
  524. $this->data['error_shipping_country'] = $this->error['shipping_country'];
  525. } else {
  526. $this->data['error_shipping_country'] = '';
  527. }
  528. if (isset($this->error['shipping_zone'])) {
  529. $this->data['error_shipping_zone'] = $this->error['shipping_zone'];
  530. } else {
  531. $this->data['error_shipping_zone'] = '';
  532. }
  533. if (isset($this->error['shipping_method'])) {
  534. $this->data['error_shipping_method'] = $this->error['shipping_method'];
  535. } else {
  536. $this->data['error_shipping_method'] = '';
  537. }
  538. $url = '';
  539. if (isset($this->request->get['filter_order_id'])) {
  540. $url .= '&filter_order_id=' . $this->request->get['filter_order_id'];
  541. }
  542. if (isset($this->request->get['filter_customer'])) {
  543. $url .= '&filter_customer=' . urlencode(html_entity_decode($this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
  544. }
  545. if (isset($this->request->get['filter_order_status_id'])) {
  546. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  547. }
  548. if (isset($this->request->get['filter_total'])) {
  549. $url .= '&filter_total=' . $this->request->get['filter_total'];
  550. }
  551. if (isset($this->request->get['filter_date_added'])) {
  552. $url .= '&filter_date_added=' . $this->request->get['filter_date_added'];
  553. }
  554. if (isset($this->request->get['filter_date_modified'])) {
  555. $url .= '&filter_date_modified=' . $this->request->get['filter_date_modified'];
  556. }
  557. if (isset($this->request->get['sort'])) {
  558. $url .= '&sort=' . $this->request->get['sort'];
  559. }
  560. if (isset($this->request->get['order'])) {
  561. $url .= '&order=' . $this->request->get['order'];
  562. }
  563. if (isset($this->request->get['page'])) {
  564. $url .= '&page=' . $this->request->get['page'];
  565. }
  566. $this->data['breadcrumbs'] = array();
  567. $this->data['breadcrumbs'][] = array(
  568. 'text' => $this->language->get('text_home'),
  569. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  570. 'separator' => false
  571. );
  572. $this->data['breadcrumbs'][] = array(
  573. 'text' => $this->language->get('heading_title'),
  574. 'href' => $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL'),
  575. 'separator' => ' :: '
  576. );
  577. if (!isset($this->request->get['order_id'])) {
  578. $this->data['action'] = $this->url->link('sale/order/insert', 'token=' . $this->session->data['token'] . $url, 'SSL');
  579. } else {
  580. $this->data['action'] = $this->url->link('sale/order/update', 'token=' . $this->session->data['token'] . '&order_id=' . $this->request->get['order_id'] . $url, 'SSL');
  581. }
  582. $this->data['cancel'] = $this->url->link('sale/order', 'token=' . $this->session->data['token'] . $url, 'SSL');
  583. if (isset($this->request->get['order_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
  584. $order_info = $this->model_sale_order->getOrder($this->request->get['order_id']);
  585. }
  586. $this->data['token'] = $this->session->data['token'];
  587. if (isset($this->request->get['order_id'])) {
  588. $this->data['order_id'] = $this->request->get['order_id'];
  589. } else {
  590. $this->data['order_id'] = 0;
  591. }
  592. if (isset($this->request->post['store_id'])) {
  593. $this->data['store_id'] = $this->request->post['store_id'];
  594. } elseif (!empty($order_info)) {
  595. $this->data['store_id'] = $order_info['store_id'];
  596. } else {
  597. $this->data['store_id'] = '';
  598. }
  599. $this->load->model('setting/store');
  600. $this->data['stores'] = $this->model_setting_store->getStores();
  601. if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
  602. $this->data['store_url'] = HTTPS_CATALOG;
  603. } else {
  604. $this->data['store_url'] = HTTP_CATALOG;
  605. }
  606. if (isset($this->request->post['customer'])) {
  607. $this->data['customer'] = $this->request->post['customer'];
  608. } elseif (!empty($order_info)) {
  609. $this->data['customer'] = $order_info['customer'];
  610. } else {
  611. $this->data['customer'] = '';
  612. }
  613. if (isset($this->request->post['customer_id'])) {
  614. $this->data['customer_id'] = $this->request->post['customer_id'];
  615. } elseif (!empty($order_info)) {
  616. $this->data['customer_id'] = $order_info['customer_id'];
  617. } else {
  618. $this->data['customer_id'] = '';
  619. }
  620. if (isset($this->request->post['customer_group_id'])) {
  621. $this->data['customer_group_id'] = $this->request->post['customer_group_id'];
  622. } elseif (!empty($order_info)) {
  623. $this->data['customer_group_id'] = $order_info['customer_group_id'];
  624. } else {
  625. $this->data['customer_group_id'] = '';
  626. }
  627. $this->load->model('sale/customer_group');
  628. $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
  629. if (isset($this->request->post['firstname'])) {
  630. $this->data['firstname'] = $this->request->post['firstname'];
  631. } elseif (!empty($order_info)) {
  632. $this->data['firstname'] = $order_info['firstname'];
  633. } else {
  634. $this->data['firstname'] = '';
  635. }
  636. if (isset($this->request->post['lastname'])) {
  637. $this->data['lastname'] = $this->request->post['lastname'];
  638. } elseif (!empty($order_info)) {
  639. $this->data['lastname'] = $order_info['lastname'];
  640. } else {
  641. $this->data['lastname'] = '';
  642. }
  643. if (isset($this->request->post['email'])) {
  644. $this->data['email'] = $this->request->post['email'];
  645. } elseif (!empty($order_info)) {
  646. $this->data['email'] = $order_info['email'];
  647. } else {
  648. $this->data['email'] = '';
  649. }
  650. if (isset($this->request->post['telephone'])) {
  651. $this->data['telephone'] = $this->request->post['telephone'];
  652. } elseif (!empty($order_info)) {
  653. $this->data['telephone'] = $order_info['telephone'];
  654. } else {
  655. $this->data['telephone'] = '';
  656. }
  657. if (isset($this->request->post['fax'])) {
  658. $this->data['fax'] = $this->request->post['fax'];
  659. } elseif (!empty($order_info)) {
  660. $this->data['fax'] = $order_info['fax'];
  661. } else {
  662. $this->data['fax'] = '';
  663. }
  664. if (isset($this->request->post['affiliate_id'])) {
  665. $this->data['affiliate_id'] = $this->request->post['affiliate_id'];
  666. } elseif (!empty($order_info)) {
  667. $this->data['affiliate_id'] = $order_info['affiliate_id'];
  668. } else {
  669. $this->data['affiliate_id'] = '';
  670. }
  671. if (isset($this->request->post['affiliate'])) {
  672. $this->data['affiliate'] = $this->request->post['affiliate'];
  673. } elseif (!empty($order_info)) {
  674. $this->data['affiliate'] = ($order_info['affiliate_id'] ? $order_info['affiliate_firstname'] . ' ' . $order_info['affiliate_lastname'] : '');
  675. } else {
  676. $this->data['affiliate'] = '';
  677. }
  678. if (isset($this->request->post['order_status_id'])) {
  679. $this->data['order_status_id'] = $this->request->post['order_status_id'];
  680. } elseif (!empty($order_info)) {
  681. $this->data['order_status_id'] = $order_info['order_status_id'];
  682. } else {
  683. $this->data['order_status_id'] = '';
  684. }
  685. $this->load->model('localisation/order_status');
  686. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  687. if (isset($this->request->post['comment'])) {
  688. $this->data['comment'] = $this->request->post['comment'];
  689. } elseif (!empty($order_info)) {
  690. $this->data['comment'] = $order_info['comment'];
  691. } else {
  692. $this->data['comment'] = '';
  693. }
  694. $this->load->model('sale/customer');
  695. if (isset($this->request->post['customer_id'])) {
  696. $this->data['addresses'] = $this->model_sale_customer->getAddresses($this->request->post['customer_id']);
  697. } elseif (!empty($order_info)) {
  698. $this->data['addresses'] = $this->model_sale_customer->getAddresses($order_info['customer_id']);
  699. } else {
  700. $this->data['addresses'] = array();
  701. }
  702. if (isset($this->request->post['payment_firstname'])) {
  703. $this->data['payment_firstname'] = $this->request->post['payment_firstname'];
  704. } elseif (!empty($order_info)) {
  705. $this->data['payment_firstname'] = $order_info['payment_firstname'];
  706. } else {
  707. $this->data['payment_firstname'] = '';
  708. }
  709. if (isset($this->request->post['payment_lastname'])) {
  710. $this->data['payment_lastname'] = $this->request->post['payment_lastname'];
  711. } elseif (!empty($order_info)) {
  712. $this->data['payment_lastname'] = $order_info['payment_lastname'];
  713. } else {
  714. $this->data['payment_lastname'] = '';
  715. }
  716. if (isset($this->request->post['payment_company'])) {
  717. $this->data['payment_company'] = $this->request->post['payment_company'];
  718. } elseif (!empty($order_info)) {
  719. $this->data['payment_company'] = $order_info['payment_company'];
  720. } else {
  721. $this->data['payment_company'] = '';
  722. }
  723. if (isset($this->request->post['payment_address_1'])) {
  724. $this->data['payment_address_1'] = $this->request->post['payment_address_1'];
  725. } elseif (!empty($order_info)) {
  726. $this->data['payment_address_1'] = $order_info['payment_address_1'];
  727. } else {
  728. $this->data['payment_address_1'] = '';
  729. }
  730. if (isset($this->request->post['payment_address_2'])) {
  731. $this->data['payment_address_2'] = $this->request->post['payment_address_2'];
  732. } elseif (!empty($order_info)) {
  733. $this->data['payment_address_2'] = $order_info['payment_address_2'];
  734. } else {
  735. $this->data['payment_address_2'] = '';
  736. }
  737. if (isset($this->request->post['payment_city'])) {
  738. $this->data['payment_city'] = $this->request->post['payment_city'];
  739. } elseif (!empty($order_info)) {
  740. $this->data['payment_city'] = $order_info['payment_city'];
  741. } else {
  742. $this->data['payment_city'] = '';
  743. }
  744. if (isset($this->request->post['payment_postcode'])) {
  745. $this->data['payment_postcode'] = $this->request->post['payment_postcode'];
  746. } elseif (!empty($order_info)) {
  747. $this->data['payment_postcode'] = $order_info['payment_postcode'];
  748. } else {
  749. $this->data['payment_postcode'] = '';
  750. }
  751. if (isset($this->request->post['payment_country_id'])) {
  752. $this->data['payment_country_id'] = $this->request->post['payment_country_id'];
  753. } elseif (!empty($order_info)) {
  754. $this->data['payment_country_id'] = $order_info['payment_country_id'];
  755. } else {
  756. $this->data['payment_country_id'] = '';
  757. }
  758. if (isset($this->request->post['payment_zone_id'])) {
  759. $this->data['payment_zone_id'] = $this->request->post['payment_zone_id'];
  760. } elseif (!empty($order_info)) {
  761. $this->data['payment_zone_id'] = $order_info['payment_zone_id'];
  762. } else {
  763. $this->data['payment_zone_id'] = '';
  764. }
  765. if (isset($this->request->post['payment_method'])) {
  766. $this->data['payment_method'] = $this->request->post['payment_method'];
  767. } elseif (!empty($order_info)) {
  768. $this->data['payment_method'] = $order_info['payment_method'];
  769. } else {
  770. $this->data['payment_method'] = '';
  771. }
  772. if (isset($this->request->post['payment_code'])) {
  773. $this->data['payment_code'] = $this->request->post['payment_code'];
  774. } elseif (!empty($order_info)) {
  775. $this->data['payment_code'] = $order_info['payment_code'];
  776. } else {
  777. $this->data['payment_code'] = '';
  778. }
  779. if (isset($this->request->post['shipping_firstname'])) {
  780. $this->data['shipping_firstname'] = $this->request->post['shipping_firstname'];
  781. } elseif (!empty($order_info)) {
  782. $this->data['shipping_firstname'] = $order_info['shipping_firstname'];
  783. } else {
  784. $this->data['shipping_firstname'] = '';
  785. }
  786. if (isset($this->request->post['shipping_lastname'])) {
  787. $this->data['shipping_lastname'] = $this->request->post['shipping_lastname'];
  788. } elseif (!empty($order_info)) {
  789. $this->data['shipping_lastname'] = $order_info['shipping_lastname'];
  790. } else {
  791. $this->data['shipping_lastname'] = '';
  792. }
  793. if (isset($this->request->post['shipping_company'])) {
  794. $this->data['shipping_company'] = $this->request->post['shipping_company'];
  795. } elseif (!empty($order_info)) {
  796. $this->data['shipping_company'] = $order_info['shipping_company'];
  797. } else {
  798. $this->data['shipping_company'] = '';
  799. }
  800. if (isset($this->request->post['shipping_address_1'])) {
  801. $this->data['shipping_address_1'] = $this->request->post['shipping_address_1'];
  802. } elseif (!empty($order_info)) {
  803. $this->data['shipping_address_1'] = $order_info['shipping_address_1'];
  804. } else {
  805. $this->data['shipping_address_1'] = '';
  806. }
  807. if (isset($this->request->post['shipping_address_2'])) {
  808. $this->data['shipping_address_2'] = $this->request->post['shipping_address_2'];
  809. } elseif (!empty($order_info)) {
  810. $this->data['shipping_address_2'] = $order_info['shipping_address_2'];
  811. } else {
  812. $this->data['shipping_address_2'] = '';
  813. }
  814. if (isset($this->request->post['shipping_city'])) {
  815. $this->data['shipping_city'] = $this->request->post['shipping_city'];
  816. } elseif (!empty($order_info)) {
  817. $this->data['shipping_city'] = $order_info['shipping_city'];
  818. } else {
  819. $this->data['shipping_city'] = '';
  820. }
  821. if (isset($this->request->post['shipping_postcode'])) {
  822. $this->data['shipping_postcode'] = $this->request->post['shipping_postcode'];
  823. } elseif (!empty($order_info)) {
  824. $this->data['shipping_postcode'] = $order_info['shipping_postcode'];
  825. } else {
  826. $this->data['shipping_postcode'] = '';
  827. }
  828. if (isset($this->request->post['shipping_country_id'])) {
  829. $this->data['shipping_country_id'] = $this->request->post['shipping_country_id'];
  830. } elseif (!empty($order_info)) {
  831. $this->data['shipping_country_id'] = $order_info['shipping_country_id'];
  832. } else {
  833. $this->data['shipping_country_id'] = '';
  834. }
  835. if (isset($this->request->post['shipping_zone_id'])) {
  836. $this->data['shipping_zone_id'] = $this->request->post['shipping_zone_id'];
  837. } elseif (!empty($order_info)) {
  838. $this->data['shipping_zone_id'] = $order_info['shipping_zone_id'];
  839. } else {
  840. $this->data['shipping_zone_id'] = '';
  841. }
  842. $this->load->model('localisation/country');
  843. $this->data['countries'] = $this->model_localisation_country->getCountries();
  844. if (isset($this->request->post['shipping_method'])) {
  845. $this->data['shipping_method'] = $this->request->post['shipping_method'];
  846. } elseif (!empty($order_info)) {
  847. $this->data['shipping_method'] = $order_info['shipping_method'];
  848. } else {
  849. $this->data['shipping_method'] = '';
  850. }
  851. if (isset($this->request->post['shipping_code'])) {
  852. $this->data['shipping_code'] = $this->request->post['shipping_code'];
  853. } elseif (!empty($order_info)) {
  854. $this->data['shipping_code'] = $order_info['shipping_code'];
  855. } else {
  856. $this->data['shipping_code'] = '';
  857. }
  858. if (isset($this->request->post['order_product'])) {
  859. $order_products = $this->request->post['order_product'];
  860. } elseif (isset($this->request->get['order_id'])) {
  861. $order_products = $this->model_sale_order->getOrderProducts($this->request->get['order_id']);
  862. } else {
  863. $order_products = array();
  864. }
  865. $this->load->model('catalog/product');
  866. $this->data['order_products'] = array();
  867. foreach ($order_products as $order_product) {
  868. if (isset($order_product['order_option'])) {
  869. $order_option = $order_product['order_option'];
  870. } elseif (isset($this->request->get['order_id'])) {
  871. $order_option = $this->model_sale_order->getOrderOptions($this->request->get['order_id'], $order_product['order_product_id']);
  872. } else {
  873. $order_option = array();
  874. }
  875. if (isset($order_product['order_download'])) {
  876. $order_download = $order_product['order_download'];
  877. } elseif (isset($this->request->get['order_id'])) {
  878. $order_download = $this->model_sale_order->getOrderDownloads($this->request->get['order_id'], $order_product['order_product_id']);
  879. } else {
  880. $order_download = array();
  881. }
  882. $this->data['order_products'][] = array(
  883. 'order_product_id' => $order_product['order_product_id'],
  884. 'product_id' => $order_product['product_id'],
  885. 'name' => $order_product['name'],
  886. 'model' => $order_product['model'],
  887. 'option' => $order_option,
  888. 'download' => $order_download,
  889. 'quantity' => $order_product['quantity'],
  890. 'price' => $order_product['price'],
  891. 'total' => $order_product['total'],
  892. 'tax' => $order_product['tax'],
  893. 'reward' => $order_product['reward']
  894. );
  895. }
  896. if (isset($this->request->post['order_voucher'])) {
  897. $this->data['order_vouchers'] = $this->request->post['order_voucher'];
  898. } elseif (isset($this->request->get['order_id'])) {
  899. $this->data['order_vouchers'] = $this->model_sale_order->getOrderVouchers($this->request->get['order_id']);
  900. } else {
  901. $this->data['order_vouchers'] = array();
  902. }
  903. $this->load->model('sale/voucher_theme');
  904. $this->data['voucher_themes'] = $this->model_sale_voucher_theme->getVoucherThemes();
  905. if (isset($this->request->post['order_total'])) {
  906. $this->data['order_totals'] = $this->request->post['order_total'];
  907. } elseif (isset($this->request->get['order_id'])) {
  908. $this->data['order_totals'] = $this->model_sale_order->getOrderTotals($this->request->get['order_id']);
  909. } else {
  910. $this->data['order_totals'] = array();
  911. }
  912. $this->template = 'sale/order_form.tpl';
  913. $this->children = array(
  914. 'common/header',
  915. 'common/footer'
  916. );
  917. $this->response->setOutput($this->render());
  918. }
  919. protected function validateForm() {
  920. if (!$this->user->hasPermission('modify', 'sale/order')) {
  921. $this->error['warning'] = $this->language->get('error_permission');
  922. }
  923. if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
  924. $this->error['firstname'] = $this->language->get('error_firstname');
  925. }
  926. if ((utf8_strlen($this->request->post['lastname']) < 1) || (utf8_strlen($this->request->post['lastname']) > 32)) {
  927. $this->error['lastname'] = $this->language->get('error_lastname');
  928. }
  929. if ((utf8_strlen($this->request->post['email']) > 96) || (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email']))) {
  930. $this->error['email'] = $this->language->get('error_email');
  931. }
  932. if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
  933. $this->error['telephone'] = $this->language->get('error_telephone');
  934. }
  935. if ((utf8_strlen($this->request->post['payment_firstname']) < 1) || (utf8_strlen($this->request->post['payment_firstname']) > 32)) {
  936. $this->error['payment_firstname'] = $this->language->get('error_firstname');
  937. }
  938. if ((utf8_strlen($this->request->post['payment_lastname']) < 1) || (utf8_strlen($this->request->post['payment_lastname']) > 32)) {
  939. $this->error['payment_lastname'] = $this->language->get('error_lastname');
  940. }
  941. if ((utf8_strlen($this->request->post['payment_address_1']) < 3) || (utf8_strlen($this->request->post['payment_address_1']) > 128)) {
  942. $this->error['payment_address_1'] = $this->language->get('error_address_1');
  943. }
  944. if ((utf8_strlen($this->request->post['payment_city']) < 3) || (utf8_strlen($this->request->post['payment_city']) > 128)) {
  945. $this->error['payment_city'] = $this->language->get('error_city');
  946. }
  947. $this->load->model('localisation/country');
  948. $country_info = $this->model_localisation_country->getCountry($this->request->post['payment_country_id']);
  949. if ($country_info) {
  950. if ($country_info['postcode_required'] && (utf8_strlen($this->request->post['payment_postcode']) < 2) || (utf8_strlen($this->request->post['payment_postcode']) > 10)) {
  951. $this->error['payment_postcode'] = $this->language->get('error_postcode');
  952. }
  953. // VAT Validation
  954. $this->load->helper('vat');
  955. if ($this->config->get('config_vat') && $this->request->post['payment_tax_id'] && (vat_validation($country_info['iso_code_2'], $this->request->post['payment_tax_id']) == 'invalid')) {
  956. $this->error['payment_tax_id'] = $this->language->get('error_vat');
  957. }
  958. }
  959. if ($this->request->post['payment_country_id'] == '') {
  960. $this->error['payment_country'] = $this->language->get('error_country');
  961. }
  962. if (!isset($this->request->post['payment_zone_id']) || $this->request->post['payment_zone_id'] == '') {
  963. $this->error['payment_zone'] = $this->language->get('error_zone');
  964. }
  965. if ($this->request->post['payment_method'] == '') {
  966. $this->error['payment_zone'] = $this->language->get('error_zone');
  967. }
  968. if (!$this->request->post['payment_method']) {
  969. $this->error['payment_method'] = $this->language->get('error_payment');
  970. }
  971. // Check if any products require shipping
  972. $shipping = false;
  973. if (isset($this->request->post['order_product'])) {
  974. $this->load->model('catalog/product');
  975. foreach ($this->request->post['order_product'] as $order_product) {
  976. $product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
  977. if ($product_info && $product_info['shipping']) {
  978. $shipping = true;
  979. }
  980. }
  981. }
  982. if ($shipping) {
  983. if ((utf8_strlen($this->request->post['shipping_firstname']) < 1) || (utf8_strlen($this->request->post['shipping_firstname']) > 32)) {
  984. $this->error['shipping_firstname'] = $this->language->get('error_firstname');
  985. }
  986. if ((utf8_strlen($this->request->post['shipping_lastname']) < 1) || (utf8_strlen($this->request->post['shipping_lastname']) > 32)) {
  987. $this->error['shipping_lastname'] = $this->language->get('error_lastname');
  988. }
  989. if ((utf8_strlen($this->request->post['shipping_address_1']) < 3) || (utf8_strlen($this->request->post['shipping_address_1']) > 128)) {
  990. $this->error['shipping_address_1'] = $this->language->get('error_address_1');
  991. }
  992. if ((utf8_strlen($this->request->post['shipping_city']) < 3) || (utf8_strlen($this->request->post['shipping_city']) > 128)) {
  993. $this->error['shipping_city'] = $this->language->get('error_city');
  994. }
  995. $this->load->model('localisation/country');
  996. $country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
  997. if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
  998. $this->error['shipping_postcode'] = $this->language->get('error_postcode');
  999. }
  1000. if ($this->request->post['shipping_country_id'] == '') {
  1001. $this->error['shipping_country'] = $this->language->get('error_country');
  1002. }
  1003. if (!isset($this->request->post['shipping_zone_id']) || $this->request->post['shipping_zone_id'] == '') {
  1004. $this->error['shipping_zone'] = $this->language->get('error_zone');
  1005. }
  1006. if (!$this->request->post['shipping_method']) {
  1007. $this->error['shipping_method'] = $this->language->get('error_shipping');
  1008. }
  1009. }
  1010. if ($this->error && !isset($this->error['warning'])) {
  1011. $this->error['warning'] = $this->language->get('err…

Large files files are truncated, but you can click here to view the full file