douxiong2999
2017-03-21 17:02
浏览 22
已采纳

prestashop 1.6 - 检查用户是否在组中

in PS 1.6 I am trying to check if user is in group with id 6 using this:

controller:

'hisGroup' => ($this->context->customer->logged AND (Customer::getDefaultGroupId((int)$this->context->customer->id) == 6) ? true : false)

tpl:

{if $hisGroup}...{/if}

although it's not working. Do you have any idea why is that?

图片转代码服务由CSDN问答提供 功能建议

在PS 1.6中,

我试图用这个来检查用户是否在ID为6的组中: \ n

控制器:

 'hisGroup'=>  ($ this-> context-> customer-> logs AND(Customer :: getDefaultGroupId((int)$ this-> context-> customer-> id)== 6)?true:false)\  n   
 
 

tpl:

  {if $ hisGroup} ... {/ if} 
    
 
 

虽然它不起作用。 你知道为什么会这样吗?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dqde43215 2017-03-21 18:53
    已采纳

    With this code you are checked the customer´s default group. To checked if customer is in a group independently of default group try this

    'inCustomerGroup' => in_array(4, Customer::getGroupsStatic($this->context->cart->id_customer)) ? true : false,
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • duangang4940 2017-03-21 17:41

    Try do it that way:

    $some = $this->context->customer->logged AND (Customer::getDefaultGroupId((int)$this->context->customer->id));
    $this->context->smarty->assign('hisGroup', $some);
    

    and in tpl:

    {if $hisGroup == 6} ... {/if}
    
    评论
    解决 无用
    打赏 举报
  • dousou2911 2017-09-05 13:49

    A simple answer is to use {Group::getCurrent()->id}. Tested with prestashop 1.6.+ Hope that help someone else

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题