Thread: A strange idea

Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2008
    Posts
    107
    Plugin Contributions
    0

    help question A strange idea

    I think that it may be useful, and in any case, I wish to try it...
    I wish to make a discount on a product from my site, and change the product every week.
    However, I wish to hide the product up to logging in, and I mean that only logged customers will be able to see the product.
    My idea was: placing a picture on the main page. Linking it to the "login" - this way the customer is redirected to the log in page.
    This is easy, and can be done. Now, I am stuck: how can I made a condition that only customers who are logged in could see the product picture with the discount and with the coupon code?
    I assume that I have to insert one, maybe more "if" or something similar - does anyone have any idea how it can be done?
    Thank you in advance!
    I'll never know how much I don't know...

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: A strange idea

    Take a look at the code in the checkout_shipping page:
    Includes/modules/pages/checkout_shipping/header_php.php

    There is a section that verifies that the customer is logged on and redirects to the login. Portions of that could be applied where necessary.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,024
    Plugin Contributions
    3

    Default Re: A strange idea


  4. #4
    Join Date
    Feb 2008
    Posts
    107
    Plugin Contributions
    0

    Default Re: A strange idea

    Quote Originally Posted by mc12345678 View Post
    Take a look at the code in the checkout_shipping page:
    Includes/modules/pages/checkout_shipping/header_php.php

    There is a section that verifies that the customer is logged on and redirects to the login. Portions of that could be applied where necessary.
    Thank you very much mc12345678!!
    I tried to find the best matching lines in header_php.php.
    I found the following:
    [QUOTE]// if there is nothing in the customers cart, redirect them to the shopping cart page
    if ($_SESSION['cart']->count_contents() <= 0) {
    zen_redirect(zen_href_link(FILENAME_TIME_OUT));
    }

    // if the customer is not logged on, redirect them to the login page
    if (!isset($_SESSION['customer_id']) || !$_SESSION['customer_id']) {
    $_SESSION['navigation']->set_snapshot();
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    } else {
    // validate customer
    if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
    $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
    } /[QUOTE]
    I assume that I have to use it, however as I am almost totally "ignorant", I must find how to use this text... Where should it be implanted? What changes / editing do I have to do?

    My site is https://www.petrutech.com

    Thank you!
    I'll never know how much I don't know...

  5. #5
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: A strange idea

    The code of importance there is the second if section
    Code:
    // if the customer is not logged on, redirect them to the login page
    if (!isset($_SESSION['customer_id']) || !$_SESSION['customer_id']) {
    $_SESSION['navigation']->set_snapshot();
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    } else {
    // validate customer
    if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
    $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
    zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
    }
    Which is what validates if the user is logged in and "active" with the site.

    That said, if I understand correctly, if customer is not logged in/valid display picture A with link to login. Else if logged in and valid then display special product with link to it. (mind you there are other things that need to be done to prevent someone from tripping over or getting to the product specifically.)

    So yeah, I used "broken" English to describe the situation, just trying to get rid of the fluff to provide the essentials.

    Anyways, could go in many of different locations, but the concept at hand is something similar to the following based on my understanding described above:

    Code:
    // if the customer is not logged on, redirect them to the login page
    if (!isset($_SESSION['customer_id']) || !$_SESSION['customer_id'] || zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
     // display "fake" image with login link.
     // here could use code taken from tpl_modules_main_product_image.php but the nuts and bolts would be like:
     echo '<a href="' . zen_href_link(FILENAME_LOGIN, '', 'SSL')  . '">' . zen_image('/* relative path to image to replace this commented out text */', 'products_name', width, height) . '</a>';
    
    } else {
     //display product with product link.
    }
    With similar code from the first section put into the else area but instead to reference your special product.

    Somewhat better than that is if you have a specific variable you plan to use on say your side box or category listing, then assign the above results to the variable and then echo the variable instead of having all that text in the applicable tpl_ file or similar for where you want it displayed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Idea?
    By dogjumps in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 18 Sep 2010, 09:16 AM
  2. An idea
    By redrob in forum General Questions
    Replies: 6
    Last Post: 17 Feb 2009, 11:27 PM
  3. strange, very strange: cookie don't work
    By 100asa in forum General Questions
    Replies: 4
    Last Post: 13 Jul 2008, 01:55 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR