Forums / General Questions / Specials Box only for logged in users

Specials Box only for logged in users

Views: 561

Results 1 to 7 of 7
29 Sep 2011, 5:22 AM
#1
jace avatar

jace

New Zenner

Join Date:
Nov 2010
Posts:
91
Plugin Contributions:
0

Specials Box only for logged in users

My website is only for wholesale customers to purchase, but also product information for the general public. It's at https://www.healthreflections.com.au. I have some items on special at the moment but want them only to be viewable by customers who are logged in.

How can I change it so only logged in customers can see the Specials sidebox?

29 Sep 2011, 5:38 PM
#2
ksookma avatar

ksookma

Zen Follower

Join Date:
Aug 2009
Posts:
212
Plugin Contributions:
1

Re: Specials Box only for logged in users

Here's the if statement you would want to apply to your sidebox.

  
if (!$_SESSION['customer_id']) {
    $show_information= false;
  } else {
    $show_information= true;
  }

If you paste your sidebox code here from modules/sideboxes/YOURTEMPLATE I can adjust it for you.

30 Sep 2011, 2:26 AM
#3
jace avatar

jace

New Zenner

Join Date:
Nov 2010
Posts:
91
Plugin Contributions:
0

Re: Specials Box only for logged in users

Here's the contents of modules/sideboxes/specials.php:

<?php
/**
 * specials sidebox - displays a random product "on special"
 *
 * @package templateSystem
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: specials.php 6475 2007-06-08 21:10:33Z ajeh $
 */

// test if box should display
if (!$_SESSION['customer_id']) {
$show_specials= false;
} else {
$show_specials= true;
}



  if (isset($_GET['products_id'])) {
    $show_specials= false;
  } else {
    $show_specials= true;
  }

  if ($show_specials == true) {
    $random_specials_sidebox_product_query = "select p.products_id, pd.products_name, p.products_price,
                                    p.products_tax_class_id, p.products_image,
                                    s.specials_new_products_price,
                                    p.master_categories_id
                             from " . TABLE_PRODUCTS . " p, " .
                                      TABLE_PRODUCTS_DESCRIPTION . " pd, " .
                                      TABLE_SPECIALS . " s
                             where p.products_status = 1
                             and p.products_id = s.products_id
                             and pd.products_id = s.products_id
                             and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                             and s.status = 1";

//    $random_specials_sidebox_product = zen_random_select($random_specials_sidebox_product_query);
    $random_specials_sidebox_product = $db->ExecuteRandomMulti($random_specials_sidebox_product_query, MAX_RANDOM_SELECT_SPECIALS);

    if ($random_specials_sidebox_product->RecordCount() > 0)  {
      require($template->get_template_dir('tpl_specials.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_specials.php');
      $title =  BOX_HEADING_SPECIALS;
      $title_link = FILENAME_SPECIALS;
      require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
  }
?>

I notice the code you suggested is already listed in the top of this file, so I'm not understanding why it still shows it anyway when you're not logged in?

30 Sep 2011, 2:33 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Specials Box only for logged in users

You have TWO IF statements testing ...

// test if box should display
if (!$_SESSION['customer_id']) {
$show_specials= false;
} else {
$show_specials= true;
}



  if (isset($_GET['products_id'])) {
    $show_specials= false;
  } else {
    $show_specials= true;
  }

So the second is overriding the first ...

Are you trying to see the specials ALWAYS when a customer is logged in or do you want to see the specials ALWAYS when a customer is logged in AND when not on the product_info page?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

30 Sep 2011, 2:40 AM
#5
jace avatar

jace

New Zenner

Join Date:
Nov 2010
Posts:
91
Plugin Contributions:
0

Re: Specials Box only for logged in users

I'm trying to have it set to always being shown on any page on the website, so it's always sitting in the right column. But more importantly, I'm needing the specials sidebox to not be shown when a user isn't logged in.

30 Sep 2011, 2:43 AM
#6
jace avatar

jace

New Zenner

Join Date:
Nov 2010
Posts:
91
Plugin Contributions:
0

Re: Specials Box only for logged in users

Ahh .. well that's done it anyway, I've removed the second IF statement and it's fixed it to how I need it. And as for putting it alongside every page, I've found the option in the Admin panel.

Cheers people :) Much appreciated!

30 Sep 2011, 12:57 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Specials Box only for logged in users

Thanks for the update that you have this working and for explaining how ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!