Search code examples
phpsmartyprestashopprestashop-1.6

prestashop 1.6 - check if user is in group


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?


Solution

  • 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,