如何获取 Prestashop 当前用户 ID? [英] How to get Prestashop current user id?

查看:54
本文介绍了如何获取 Prestashop 当前用户 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码尝试在 prestashop 中获取当前用户 ID..我将此代码放在我的模块目录中的另一个 php 文件中,并通过模块文件调用它.

I used the below code to try to get the current user ID in prestashop.. am placing this code in another php file in my module directory and call it through by the module file.

 $id = $this->context->customer->id_customer;

但它对我不起作用..我使用的是 prestashop 1.5 ..

but its not working for me.. am using prestashop 1.5 ..

推荐答案

我当然也无法在我的测试中使用它.不过你可以试试

I certainly couldn't get it to work in my test either. However, you can try

$id = (int)$this->context->cookie->id_customer;

这对我有用.不过,我完全不确定这是最好的方法.

which works for me. I'm not at all sure that this is the best way to do it though.

这篇关于如何获取 Prestashop 当前用户 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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