OpenCart 🇺🇦

Схема

public mixed index ( )

Аргументы

Аргумент Возможный тип Описание
У метода нет аргументов

Описание

Метод пока еще не документирован.

Исходный код

if (!$this->customer->isLogged()) {
	$this->session->data['redirect'] = $this->url->link('account/order', '', 'SSL');

	$this->redirect($this->url->link('account/login', '', 'SSL'));
}

$this->language->load('account/order');

$this->load->model('account/order');

if (isset($this->request->get['order_id'])) {
	$order_info = $this->model_account_order->getOrder($this->request->get['order_id']);

	if ($order_info) {
		$order_products = $this->model_account_order->getOrderProducts($this->request->get['order_id']);

		foreach ($order_products as $order_product) {
			$option_data = array();

			$order_options = $this->model_account_order->getOrderOptions($this->request->get['order_id'], $order_product['order_product_id']);

			foreach ($order_options as $order_option) {
				if ($order_option['type'] == 'select' || $order_option['type'] == 'radio') {
					$option_data[$order_option['product_option_id']] = $order_option['product_option_value_id'];
				} elseif ($order_option['type'] == 'checkbox') {
					$option_data[$order_option['product_option_id']][] = $order_option['product_option_value_id'];
				} elseif ($order_option['type'] == 'text' || $order_option['type'] == 'textarea' || $order_option['type'] == 'date' || $order_option['type'] == 'datetime' || $order_option['type'] == 'time') {
					$option_data[$order_option['product_option_id']] = $order_option['value'];	
				} elseif ($order_option['type'] == 'file') {
					$option_data[$order_option['product_option_id']] = $this->encryption->encrypt($order_option['value']);
				}
			}

			$this->session->data['success'] = sprintf($this->language->get('text_success'), $this->request->get['order_id']);

			$this->cart->add($order_product['product_id'], $order_product['quantity'], $option_data);
		}

		$this->redirect($this->url->link('checkout/cart'));
	}
}

$this->document->setTitle($this->language->get('heading_title'));

$this->data['breadcrumbs'] = array();

$this->data['breadcrumbs'][] = array(
	'text'      => $this->language->get('text_home'),
	'href'      => $this->url->link('common/home'),        	
	'separator' => false
);

$this->data['breadcrumbs'][] = array(
	'text'      => $this->language->get('text_account'),
	'href'      => $this->url->link('account/account', '', 'SSL'),        	
	'separator' => $this->language->get('text_separator')
);

$url = '';

if (isset($this->request->get['page'])) {
	$url .= '&page=' . $this->request->get['page'];
}

$this->data['breadcrumbs'][] = array(
	'text'      => $this->language->get('heading_title'),
	'href'      => $this->url->link('account/order', $url, 'SSL'),        	
	'separator' => $this->language->get('text_separator')
);

$this->data['heading_title'] = $this->language->get('heading_title');

$this->data['text_order_id'] = $this->language->get('text_order_id');
$this->data['text_status'] = $this->language->get('text_status');
$this->data['text_date_added'] = $this->language->get('text_date_added');
$this->data['text_customer'] = $this->language->get('text_customer');
$this->data['text_products'] = $this->language->get('text_products');
$this->data['text_total'] = $this->language->get('text_total');
$this->data['text_empty'] = $this->language->get('text_empty');

$this->data['button_view'] = $this->language->get('button_view');
$this->data['button_reorder'] = $this->language->get('button_reorder');
$this->data['button_continue'] = $this->language->get('button_continue');

if (isset($this->request->get['page'])) {
	$page = $this->request->get['page'];
} else {
	$page = 1;
}

$this->data['orders'] = array();

$order_total = $this->model_account_order->getTotalOrders();

$results = $this->model_account_order->getOrders(($page - 1) * 10, 10);

foreach ($results as $result) {
	$product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
	$voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);

	$this->data['orders'][] = array(
		'order_id'   => $result['order_id'],
		'name'       => $result['firstname'] . ' ' . $result['lastname'],
		'status'     => $result['status'],
		'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
		'products'   => ($product_total + $voucher_total),
		'total'      => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
		'href'       => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], 'SSL'),
		'reorder'    => $this->url->link('account/order', 'order_id=' . $result['order_id'], 'SSL')
	);
}

$pagination = new Pagination();
$pagination->total = $order_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('account/order', 'page={page}', 'SSL');

$this->data['pagination'] = $pagination->render();

$this->data['continue'] = $this->url->link('account/account', '', 'SSL');

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/order_list.tpl')) {
	$this->template = $this->config->get('config_template') . '/template/account/order_list.tpl';
} else {
	$this->template = 'default/template/account/order_list.tpl';
}

$this->children = array(
	'common/column_left',
	'common/column_right',
	'common/content_top',
	'common/content_bottom',
	'common/footer',
	'common/header'	
);

$this->response->setOutput($this->render());