Forums / Templates, Stylesheets, Page Layout / Product URL on tpl_product_info_display.php to display only when user is logged in?

Product URL on tpl_product_info_display.php to display only when user is logged in?

Views: 1,865

Results 1 to 3 of 3
23 Oct 2013, 3:29 PM
#1
matt_staines avatar

matt_staines

New Zenner

Join Date:
Oct 2013
Location:
Portishead, North Somerset, United Kingdom
Posts:
34
Plugin Contributions:
0

Product URL on tpl_product_info_display.php to display only when user is logged in?

Hi everyone, can somebody please help me out with the following:

Product Page - I'm wanting to amend a small portion for my websites benefit.

On the 'tpl_product_info_display.php' or 'Product Page' as we know it , I would like the "product URL" section below to only appear when the user is logged in. I know I need to do something with checking the session, but do not have the PHP knowledge to sort this.

To display this segment when the user is logged in only, else display nothing:

<!--bof Product URL -->
<?php
  if (zen_not_null($products_url)) {
    if ($flag_show_product_info_url == 1) {
?>
    <p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url), 'NONSSL', true, false)); ?></p>
<?php
    } // $flag_show_product_info_url
  }
?>
<!--eof Product URL -->

The reason for doing this is because I am using the URL to link to another website that is for logged in users only (but does not need to be strictly secure) and it needs to come from each specific product page.

Any help appreciated.

Thanks

23 Oct 2013, 4:03 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Product URL on tpl_product_info_display.php to display only when user is logged in?

You can add a condition to see if a customer's currently logged in:

<!--bof Product URL -->
<?php
  if (zen_not_null($products_url) && isset($_SESSION['customer_id'])) {
    if ($flag_show_product_info_url == 1) {
?>
    <p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url), 'NONSSL', true, false)); ?></p>
<?php
    } // $flag_show_product_info_url
  }
?>
<!--eof Product URL -->
24 Oct 2013, 8:39 AM
#3
matt_staines avatar

matt_staines

New Zenner

Join Date:
Oct 2013
Location:
Portishead, North Somerset, United Kingdom
Posts:
34
Plugin Contributions:
0

Re: Product URL on tpl_product_info_display.php to display only when user is logged in?

Works perfectly, I wish that I knew PHP.

Many Thanks Lat9!