Man*_*nik 6 custom-error-pages prestashop
我使用下面的代码尝试获取prestashop中的当前用户ID ..我将此代码放在我的模块目录中的另一个php文件中,并通过模块文件调用它.
$id = $this->context->customer->id_customer;
Run Code Online (Sandbox Code Playgroud)
但它不适合我..我正在使用prestashop 1.5 ..
jos*_*ich 12
我当然也无法在我的测试中使用它.但是,你可以试试
$id = (int)$this->context->cookie->id_customer;
Run Code Online (Sandbox Code Playgroud)
这适合我.我完全不确定这是最好的方法.
首先检查用户是否登录而不是获取id $this->context->customer->id_customer
if ($this->context->customer->isLogged()) {
echo $this->context->customer->id_customer;
}
else{
echo 'Not LoggedIn';
}
Run Code Online (Sandbox Code Playgroud)