在opencart 2上的header.tpl中显示客户ID



如何在opencart上的header.tpl中显示客户ID?

    if ($this->customer->isLogged()) {
    $data['customer_id'] = $this->customer->getId(); // customer ID
    $data['customer_fname'] = $this->customer->getFirstName(); // customer email
    }

不起作用。

在header.php文件中添加此两个变量

if ($this->customer->isLogged()) { // <-- This line is around 52
    $this->load->model('account/wishlist');
    $data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist());
    $data['customer_id'] = $this->customer->getId(); // <-- add this variable
    $data['customer_fname'] = $this->customer->getFirstName(); // <-- and this variable
} else {
    $data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
}

在header.tpl文件中,您可以使用这样的变量,必须在if ($logged)块内部

<?php if ($logged) { ?>
<?php echo $customer_id; ?>
<?php echo $customer_fname; ?>
<?php } ?>

在OC 2.2.0.0

上测试

最新更新