Здравствуйте, подскажите пожалуйста как вывести общие количество бонусных балов в корзину.
Вот исходный код.
<div class="cart">
<div class="info">
<div class="ico"></div>
<div class="info-cart">
<div class="count"><?php echo $text_items; ?></div>
<div class="name"><?php echo $text_tems; ?></div>
</div>
</div>
<div class="list-cart">
<?php if ($products || $vouchers) { ?>
<div class="list-items-cart">
<?php foreach ($products as $product) { ?>
<div class="list-item">
<div class="image">
<img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" />
</div>
<a class="title">
<?php echo $product['name']; ?>
</a>
<div class="count">
<span class="minus-count">-</span>
<input type="text" name="count" value="<?php echo $product['quantity']; ?>" />
<span class="plus-count">+</span>
</div>
<div class="price-bonus">
<div class="price"><?php echo $product['total']; ?></div>
<div class="bonus"><?php echo $product['reward']; ?></div>
</div>
<button type="button" onclick="cart.remove('<?php echo $product['cart_id']; ?>');" title="<?php echo $button_remove; ?>" class="remove-item"></button>
</div>
<?php } ?>
<div class="show-all">
и еще <span>3</span> товара
</div>
</div>
<div class="info-order">
<div class="prices">Стоимость <span><?php echo $total['text']; ?></span></div>
<div class="bonus"><span>50</span> бонусов</div>
</div>
<div class="bottom-part">
<a href="<?php echo $cart; ?>" class="btn btn-clear">Очистить корзину</a>
<a href="<?php echo $checkout; ?>" class="btn btn-order"><?php echo $text_checkout; ?></a>
</div>
<?php } else { ?>
<div class="list-items-cart"><?php echo $text_empty; ?></div>
<?php } ?>
</div>
</div>
<?php
class ControllerCommonCart extends Controller {
public function index() {
$this->load->language('common/cart');
// Totals
$this->load->model('extension/extension');
$totals = array();
$taxes = $this->cart->getTaxes();
$total = 0;
// Because __call can not keep var references so we put them into an array.
$total_data = array(
'totals' => &$totals,
'taxes' => &$taxes,
'total' => &$total
);
// Display prices
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$sort_order = array();
$results = $this->model_extension_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('extension/total/' . $result['code']);
// We have to put the totals in an array so that they pass by reference.
$this->{'model_extension_total_' . $result['code']}->getTotal($total_data);
}
}
$sort_order = array();
foreach ($totals as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $totals);
}
$data['text_empty'] = $this->language->get('text_empty');
$data['text_cart'] = $this->language->get('text_cart');
$data['text_checkout'] = $this->language->get('text_checkout');
$data['text_recurring'] = $this->language->get('text_recurring');
$data['text_tems'] = $this->language->get('text_tems');
$data['text_items'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->session->data['currency']));
$data['text_loading'] = $this->language->get('text_loading');
$data['button_remove'] = $this->language->get('button_remove');
$this->load->model('tool/image');
$this->load->model('tool/upload');
$data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get($this->config->get('config_theme') . '_image_cart_width'), $this->config->get($this->config->get('config_theme') . '_image_cart_height'));
} else {
$image = '';
}
$option_data = array();
foreach ($product['option'] 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),
'type' => $option['type']
);
}
// Display prices
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'));
$price = $this->currency->format($unit_price, $this->session->data['currency']);
$total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']);
} else {
$price = false;
$total = false;
}
$data['products'][] = array(
'cart_id' => $product['cart_id'],
'thumb' => $image,
'name' => $product['name'],
'model' => $product['model'],
'upc' => $product['upc'],
'sku' => $product['sku'],
'reward' => $product['reward'],
'reviews' => $product['reviews'],
'option' => $option_data,
'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''),
'quantity' => $product['quantity'],
'price' => $price,
'total' => $total,
'href' => $this->url->link('product/product', 'product_id=' . $product['product_id'])
);
}
// Gift Voucher
$data['vouchers'] = array();
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $key => $voucher) {
$data['vouchers'][] = array(
'key' => $key,
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency'])
);
}
}
$data['totals'] = array();
foreach ($totals as $total) {
$data['totals'][] = array(
'title' => $total['title'],
'text' => $this->currency->format($total['value'], $this->session->data['currency']),
);
}
$data['cart'] = $this->url->link('checkout/cart');
$data['checkout'] = $this->url->link('checkout/checkout', '', true);
return $this->load->view('common/cart', $data);
}
public function info() {
$this->response->setOutput($this->index());
}
}