the field name of user id is id_customer and I'm using prestashop 1.6.1.3 I already tried on this
$id = $this->context->customer->id_customer;
this
$id = (int)$this->context->cookie->id_customer;
this
if ($this->context->customer->isLogged()) {
echo $this->context->customer->id_customer;
}
else{
echo 'Not LoggedIn';
}
and this
$id_customer = null;
if ($this->context->customer->isLogged()) {
// code to execute if i am logued
$id_customer = $this->context->customer->id;
}
but it's not working ..., can someone help me? thx
*also if you have a tpl function to get id session, let me know.
Instead of calling $this
which depends of the controller / module you're working with. You can call directly the singleton Context
object like this:
if (Context::getContext()->customer->id)
{
$id_customer = Context::getContext()->customer->id;
}
else
{
$id_customer = false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.