在 Prestashop 中获取客户 id_default_group
Get customer id_default_group in Prestashop
我需要在 TPL 文件中检查客户 id_default_group。
喜欢
{$cookie->customer_firstname}
但是这段代码
{$cookie->id_default_group}
无效!
如何获取客户登录时的ID组?
php
试试这个
$this->context->customer->id_default_group; // your variable to be used
或
$context = Context::getContext();
$context->customer->id_default_group; // your variable to be used
.tpl
如果你想在 .tpl
中使用它,首先你需要将你的变量传递给你的模板文件,写成 php
.
$this->context->smarty->assign(array(
'customer' => $this->context->customer
));
然后在.tpl
中使用
{if isset($customer->id_default_group)}
{$customer->id_default_group|intval}
{/if}
在PS 1.6.15 我使用
{Group::getCurrent()->id}
也许这对你也有用。
我需要在 TPL 文件中检查客户 id_default_group。
喜欢
{$cookie->customer_firstname}
但是这段代码
{$cookie->id_default_group}
无效!
如何获取客户登录时的ID组?
php
试试这个
$this->context->customer->id_default_group; // your variable to be used
或
$context = Context::getContext();
$context->customer->id_default_group; // your variable to be used
.tpl
如果你想在 .tpl
中使用它,首先你需要将你的变量传递给你的模板文件,写成 php
.
$this->context->smarty->assign(array(
'customer' => $this->context->customer
));
然后在.tpl
{if isset($customer->id_default_group)}
{$customer->id_default_group|intval}
{/if}
在PS 1.6.15 我使用
{Group::getCurrent()->id}
也许这对你也有用。