使用OpenCart 2.0。如何在类别页面上显示客户的电子邮件? [英] Using OpenCart 2.0. How do I display customers email on a category page?

查看:126
本文介绍了使用OpenCart 2.0。如何在类别页面上显示客户的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCart 2.0,当用户登录时,我试图在类别页面上显示用户电子邮件。下面的代码可以在success.tpl上显示用户的电子邮件。如何在类别页面上显示?感谢您的时间。

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

IN: /catalog/controller/product/category.php

我有这个:

 $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

THEN IN:/catalog/view/theme/default/template/category.tpl

我有这个:

<?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

$this->customer->getEmail();

请注意,在2.0中,您不能只在模板中回应此内容,您需要将其分配给控制器到$ data数组,然后使用模板中的值。要将其添加到模板中的快速入侵是使用

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

<?php
global $customer;
echo $customer->getEmail();
?>

但不推荐

这篇关于使用OpenCart 2.0。如何在类别页面上显示客户的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆