Using the number of items in the cart in header.tpl
Posted: Wed May 12, 2010 2:48 am
Hello Folks,
Im developing a site for a client and its the first time i've tried to work with opencart so im not 100% sure about the best way to do things, i could do with some advice.
I have added the following code to the header controller in controllers/common/header.php
So this has the affect of lettign me use $cart_count in my header template.
Is the correct way to go about modifying opencart? It doesn't seem like its very upgrade proof.
Thanks
Im developing a site for a client and its the first time i've tried to work with opencart so im not 100% sure about the best way to do things, i could do with some advice.
I have added the following code to the header controller in controllers/common/header.php
Code: Select all
if (isset($this->session->data['cart']) && !empty($this->session->data['cart'])) {
$this->data['cart_count'] = array_sum($this->session->data['cart']);
}else{
$this->data['cart_count'] = 0;
}
Is the correct way to go about modifying opencart? It doesn't seem like its very upgrade proof.
Thanks