2
function get_user_id() 
{
    global $cookie;
    $userid = NULL;

    if (isset($cookie->id_customer))
    {
        $userid = $cookie->id_customer;
    }

    return $userid;
}

为什么即使登录,用户 ID 仍然返回 null?

4

2 回答 2

9

如果使用 Prestashop 1.5 使用Contextobject 代替:

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

或者

Context::getContext()->customer->id

如果没有从父类继承的上下文。

于 2013-08-29T19:22:54.190 回答
0

$params['cookie']->id_customer

你不应该使用全局变量。

于 2013-04-24T20:40:39.690 回答