Вывод списка товаров в истории заказов (order_list.twig) OpenCart 3.x
В файле контроллера ("/catalog/controller/account/order.php")
Найти
$data['orders'][] = array(
Добавить выше
// List Products
$data['products'] = array();
$products = $this->model_account_order->getOrderProducts($result['order_id']);
foreach ($products as $product) {
$option_data = array();
$options = $this->model_account_order->getOrderOptions($result['order_id'], $product['order_product_id']);
foreach ($options as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
if ($upload_info) {
$value = $upload_info['name'];
} else {
$value = '';
}
}
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
}
$data['products'][] = array(
'name' => $product['name'],
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'], true),
'model' => $product['model'],
'option' => $option_data,
'quantity' => $product['quantity'],
'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
'reorder' => $reorder,
'return' => $this->url->link('account/return/add', 'order_id=' . $order_info['order_id'] . '&product_id=' . $product['product_id'], true)
);
}
Найти
'products' => ($product_total + $voucher_total),
Ниже добавить
'list' => $data['list_products'],
В файле шаблона ("/catalog/view/theme/default/template/account/order_list.twig")
Найти
{% for order in orders %}
Ниже, в нужном месте (до {% endfor %}), вставить и стилизовать под себя
{% for product in order.products %}
<ul>
<li class="name"><a href="{{ product.href }}">{{ product.name }}</a></li>
<li class="option">{% for option in product.option %}<br /> <small> - {{ option.name }}: {{ option.value }}</small>{% endfor %}</li>
<li class="model">{{ product.model }}</li>
<li class="quantity">{{ product.quantity }}</li>
<li class="price">{{ product.price }}</li>
<li class="total">{{ product.total }}</li>
<li class="reorder">{% if product.reorder %}<a href="{{ product.reorder }}"> </a>{% endif %}</li>
<li class="return"><a href="{{ product.return }}"> </a></li>
</ul>
{% endfor %}
Готово