I'm using OpenCart 2.0 and I'm trying to show a user email on a category page when a user is logged in. The code below I believe works for it to show a users email on the success.tpl. How can I display it on a category page? Thanks for your time.
IN: /catalog/controller/product/category.php
I HAVE THIS:
$this->load->model('account/order');
$order = $this->model_account_order->getOrder($this->session->data['order_id']);
if($order) {
$this->data['email'] = $order['email'];
}
THEN IN:/catalog/view/theme/default/template/category.tpl
I HAVE THIS:
<?php if(!empty($email)) echo $email; ?>
This is part of the core library. You don't need to look up an order if they're logged in, you just need to use
Note that in 2.0 you can't just echo this in a template, you need to assign this in the controller to the $data array and then use the value in the template. A quick hack to just add it to the template is to use
but really isn't recommended