Jump to content

[SOLVED] Display a div only for a specific User Group


Recommended Posts

well, it's still not enough for me. So i will show you how to do it for homepage (not modules) - just for theme.

 

open classes/controllers/frontController.php

 

 

there is a function:

public function initContent()
{ 

add there this code:

$this->context->smarty->assign('checkcustomer',$this->context->customer);

example:

public function initContent()
{
$this->context->smarty->assign('checkcustomer',$this->context->customer);

then in .tpl files use this code:

{if $checkcustomer->id_default_group==3}
CONTENT HERE
{/if}

where 3 is an ID of customer group.

Ss8KVSe.png

  • Like 5
Link to comment
Share on other sites

  • 2 months later...

Hello,

I need to do something like this but not on homepage

i have installed a module (for display discount price on product page) and i have put this code in product-list.tpl (for display cheapest price on the product list in category) :

        {if isset($is_agilequantitydiscountindicator_installed)}
            <script language="javascript" type="text/javascript">
            $(document).ready(function() 
            {ldelim} 
	            getQDIPriceForList({$product.id_product}); 
            {rdelim}
            );
            </script>

So here is my probleme, i have 2 differents groups : normal customers, and VIP

For the normal customer, all work fine

but for VIP i have a probleme, i want to hide this code (and module) for the VIP group for 2 reasons :

first : VIP dont have more than 1 discount price (Normal customer have 5 discount price) so it's useless to display it on product page.

second : The price displayed on product list dont work when the discount price is setting on "1" on quantity minimum, the price display on the product list is the higher.

 

So i just want to hide the code for VIP and display for normal

 

it is possible ?

 

Thank's for futures answers and i'm sorry for my bad english, i hope it's understandable :D

 

ps : Presta 1.5.4.1

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

  • 2 months later...

well, it's still not enough for me. So i will show you how to do it for homepage (not modules) - just for theme.

 

open classes/controllers/frontController.php

 

 

there is a function:

public function initContent()
{ 

add there this code:

$this->context->smarty->assign('checkcustomer',$this->context->customer);

example:

public function initContent()
{
$this->context->smarty->assign('checkcustomer',$this->context->customer);

then in .tpl files use this code:

{if $checkcustomer->id_default_group==3}
CONTENT HERE
{/if}

where 3 is an ID of customer group.

Ss8KVSe.png

 

Hello there. Thank you for this advice, exactly what i was looking for. However i encountered a little problem. I placed a unique content based on customer`s group id into product-list.tpl and product.tpl. It works fine on both, except when you have more than one page of products and go to second page (processed by script i guess), the condition is not processed anymore and the conditional content is not displayed anymore.

 

My product-list.tpl: 

{if $logged}{if $checkcustomer->id_default_group==5}<span id="old_price_display">{convertPrice price=$product.price * 1.25}</span><br />{/if}{/if}

My frontController.php is exactly to your specifications.

 

THanks for help

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...