Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2010
    Posts
    87
    Plugin Contributions
    0

    red flag 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 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?

  2. #2
    Join Date
    Aug 2009
    Posts
    210
    Plugin Contributions
    1

    Default Re: Specials Box only for logged in users

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

    Code:
      
    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.

  3. #3
    Join Date
    Nov 2010
    Posts
    87
    Plugin Contributions
    0

    Default Re: Specials Box only for logged in users

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

    Code:
    <?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?

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Specials Box only for logged in users

    You have TWO IF statements testing ...

    Code:
    // 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!

  5. #5
    Join Date
    Nov 2010
    Posts
    87
    Plugin Contributions
    0

    Default 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.

  6. #6
    Join Date
    Nov 2010
    Posts
    87
    Plugin Contributions
    0

    Default 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!

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Specials Box only for logged in users

    Thanks for the update that you have this working and for explaining how ...
    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!

 

 

Similar Threads

  1. sidebox module for logged in users only
    By amat78 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 21 Apr 2011, 08:19 PM
  2. Persistent header links across CMS' for seamless logged in users?
    By swamyg1 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 28 Mar 2011, 10:09 AM
  3. Replies: 4
    Last Post: 5 Jun 2010, 01:44 PM
  4. Adding a PDF file accessible only to logged in users
    By Heyzoos in forum General Questions
    Replies: 1
    Last Post: 30 Aug 2007, 05:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg