Jump to content

Hide Product Features unless logged in.


Tusa Products

Recommended Posts

Hello all. I'm having troubles getting product.tpl and product-details.tpl to access the $logged variable, as referenced in many threads over many forums whose solutions I've been attempting to implement all day. 

 

What I'm trying to accomplish in product.tpl is to prevent loading product-details.tpl unless the user is logged in. The simplest way I've tried to implement it is this:

 

{if $logged}
               {block name='product_details'}
                 {include file='catalog/_partials/product-details.tpl'}
               {/block}
{/if}
 
However, $logged is always shown as false, even when the a customer is logged in, meaning that this is always hidden.
 
I am using Prestashop 1.7 with a modified theme, but the only references to the $logged variable are as normal in the Cookie.php. 
 
Having read up on the issue a bunch, I am thinking that my issue is that product.tpl is reading from Product.php and not the cookie, but I've not had any luck getting product.tpl to do anything useful.
 
Any help anyone could give would be great. Thank you.
Link to comment
Share on other sites

I think the problem with this approach is that you only cover one price display scenario, i.e. best sales/featured/etc etc....

 

I'm new to template inheritance so I'm curious if the one solution worked for price display 'everywhere"?

  • Like 1
Link to comment
Share on other sites

I think the problem with this approach is that you only cover one price display scenario, i.e. best sales/featured/etc etc....

 

I'm new to template inheritance so I'm curious if the one solution worked for price display 'everywhere"?

 

In my particular scenario it's not necessary, but based on BalzoT's post, I went into classes/Customer.php, where $is_guest is defined. Also defined in that file is $id_default_group. I haven't tried it, but it should work similarly based on a customer's default group rather than just a logged in, logged out situation.

 

Edit to add:

 

In fact, looking deeper through, you could pare down your settings to a number of very specific levels should you so choose without having to define your own variables. In classes/controller/FrontController.php, where the is_logged seems to be defined, there are a number of other fields which you could use via smarty with $customer. A few I noticed at a glance were $customer.gender, $customer.id_risk (from the risk setting in the back end for customers).  Even as specific as $customer.id_customer if you want to tailor specific content to specific customers. Not much need in a retail situation for that, but it could be beneficial in a fully Business to Business set up, as mine is.

Edited by Tusa Products (see edit history)
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...