OK, I think I've sussed the first part of it.
Looking through the Database structure and the data already available, it seemed to me like I'd have to create this myself, rather than just reference it.
So, in
catalog/controller/common/header.php, I added this method:
Code: Select all
public function getCustomerDetails($customer_id){
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
$query1 = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$customer_id . "'");
$query->row = array_merge($query->row,$query1->row);
return $query->row;
}
which gives me this extra array of data to play with:
Code: Select all
Array
(
[customer_id] => 2
[store_id] => 0
[firstname] => Andy
[lastname] => SURNAME
[email] => me@mydomain.com
[telephone] => 12345 6789012
[fax] =>
[password] => 70ae291a4e7365bhafsohfc5ba8b618cab
[cart] => a:4:{i:51;i:1;i:55;i:1;s:10:"79:613.616";i:4;s:10:"79:619.622";i:1;}
[newsletter] => 0
[address_id] => 3
[status] => 1
[approved] => 1
[customer_group_id] => 6
[ip] => 123.456.789.012
[date_added] => 2011-05-31 00:33:59
[company] => My Company Ltd
[address_1] => My Address
[address_2] => My Address
[postcode] => My Postcode
[city] => York
[country_id] => 222
[zone_id] => 3576
)
and now in
catalog/view/theme/MYTHEME/template/common/header.tpl, I have this:
Code: Select all
<?php
$customer_details = $this->getCustomerDetails($this->customer->isLogged());
?>
so I can get the company name like this (or indeed, any of the variables contained in that array):
Code: Select all
<?php
echo $customer_details['company'];
?>
Now, I
REALLY wanted to merge the data from the address DB table into the current Customer Object, but I still can't get my head around this OC MVC malarky. If anyone could point me in the right direction to make this neater, or has any other suggestions to help in my other quests, they'd be greatly appreciated.
Cheers