Jump to content

[SOLVED]Check if current user is in a certain group in produit.tpl


alamise

Recommended Posts

Hello everyone, 

 

I hope some of you can help .

this makes me struggle from a couple of days.

I have already found 1-2 similar topics, but nothing worked for me. 

 

how can i get current customer group id in produit.tpl

 

Thnaks in advance!

 

prestashop 1.5.6.2

Edited by alamise (see edit history)
Link to comment
Share on other sites

Hi Alamise,

In controllers/front/ProductController.php

find function public function initContent()

 
Then just before the call to product.tpl add the current group:
 
    'ENT_NOQUOTES' => ENT_NOQUOTES,
    'currentGroup' => (int)Group::getCurrent()->id,
    'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK')
    ));
  }
 
  $this->context->smarty->assign('errors', $this->errors);
  $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
}
 
then in themes/<your theme folder>/product.tpl, add somewhere where you need it:
 
 <span id="current_group_id">Current group = {$currentGroup}</span>

 

or something like that.

 

Hope this helps,

pascal

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...