Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Default Product Notification In Product Info Page?

    Picking up from the now-archived thread:
    http://www.zen-cart.com/forum/showthread.php?t=34691

    I asked if the Product Notifications sidebox content could be copied into an available table cell on the Product Info page (v 1.2.7 and lower)...

    Ajeh, in your last reply, you said:
    "Get the code from when the sidebox is set to NO ... then write a cute little IF to controll it ... :)"

    By this, do you mean I should use the code from both tpl_no_notifications.php and tpl_yes_notifications.php and add the IF, or use only the tpl_no_notifications.php code with an IF?

    I have only written very rudimentary IFs to this point, so this ought to be interesting! :)

    chrx

  2. #2
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Re: Product Notification In Product Info Page?

    Bump for some further suggestions?

    Thanks,
    chrx

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

    Default Re: Product Notification In Product Info Page?

    That is correct ...

    You are making the code work like the sidebox but in the middle of your product _info page ...

    So, more or less you need the yes and no portions to accomplish this from the two parts ...

    This can be controlled with an IF statement just like the sidebox does now ...
    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!

  4. #4
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Default Re: Product Notification In Product Info Page?

    Thanks for throwing me some more clues, Ajeh!

    I'm a little closer, and thought I'd run some of my discovery process by you (I hope this sin't too much info all at once)...

    My first step was to test the YES and NO first, before adding the IF to see if it functions outside the sidebox environment:

    I dropped both the "Notify Me" and "Don't Notify Me" lines from tpl_no_notifications.php and tpl_yes_notifications.php respectively (line 23 in both cases) and both buttons show up together on the page in all cases. The "Notify Me" adds the product to my notification list and the "Don't Notify Me" removes it, just like it is supposed to work (I assume) so it appears the Notify functionality is comfortable outside the sidebox so far. Again, regardless of the current status of the notification, both buttons show up; this because I "forced" them to display by surrounding them in <?php echo ?> functions.

    This is how it looks in the my_template/templates/tpl_product_info_display.php file at this point:

    ---------- begin testing code ----------
    <td align="left" colspan="1">

    <!-- FROM NO_NOTIFICATIONS -->
    <?php echo '<div class="sideBoxContents" align="center"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_YES, OTHER_BOX_NOTIFY_YES_ALT) . '</a><br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, zen_get_products_name($_GET['products_id'])) .'</a></div>'; ?>

    <!-- FROM YES_NOTIFICATIONS -->
    <?php echo '<div class="sideBoxContents" align="center"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_REMOVE, OTHER_BOX_NOTIFY_REMOVE_ALT) . '<br />' . sprintf(BOX_NOTIFICATIONS_NOTIFY_REMOVE, zen_get_products_name($_GET['products_id'])) .'</a></div>'; ?>

    </td>
    ---------- end testing code ----------

    So next, based on my understanding of your response, I'll need to remove the <?php echo ?> functions I added here, then add the IF statement from /includes/modules/sideboxes/product_notifications.php

    I assume I'll also need to add the $content = ""; from line 22 of tpl_yes_notifications.php and tpl_no_notifications.php to the YES and NO lines here as well, so it appears like this before I add the IF:

    ---------- begin testing code ----------
    <td align="left" colspan="1">

    <!-- FROM NO_NOTIFICATIONS -->
    $content = "";
    $content .= '<div class="sideBoxContents" align="left"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_YES, OTHER_BOX_NOTIFY_YES_ALT) . '</a><br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, zen_get_products_name($_GET['products_id'])) .'</a></div>'; ?>

    <!-- FROM YES_NOTIFICATIONS -->
    $content = "";
    $content .= '<div class="sideBoxContents" align="left"><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify_remove', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_REMOVE, OTHER_BOX_NOTIFY_REMOVE_ALT) . '<br />' . sprintf(BOX_NOTIFICATIONS_NOTIFY_REMOVE, zen_get_products_name($_GET['products_id'])) .'</a></div>'; ?>

    </td>
    ---------- end testing code ----------

    This is my first attempt at a move like this, so I'm trying to track down everything I need to piece this together.

    Thanks again,
    chrx
    Last edited by chrx; 16 May 2006 at 05:46 PM.

  5. #5
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Idea or Suggestion Re: Product Notification In Product Info Page!

    Finally figured it all out.

    First:
    The files involved for this (my) version of the Product Notifications transplant into the Product Info page include:

    /includes/modules/sideboxes/product_notifications.php

    /templates/template_default/common/tpl_box_default_single.php

    /includes/templates/my_template/templates/tpl_product_info_display.php

    /includes/templates/my_template/tpl_no_notifications.php

    /includes/templates/my_template/tpl_yes_notifications.php


    How it went together and code snippets to follow later!

    Cheers,
    chrx

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

    Default Re: Product Notification In Product Info Page?

    Thanks for the update chrx ... looking forward to seeing what you have done ...
    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!

  7. #7
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Default Re: Product Notification In Product Info Page!

    I'll take this one file at a time, for a step-by-step approach.

    *Keep in mind that this applies to ZC v1.2.7, so newer versions may have some differences in the template code.*

    I'll start with:
    /includes/templates/my_template/templates/tpl_product_info_display.php

    This is the page where I wanted the Product Notification function to live, so this is the first place I looked.

    I decided to put the Notification function below the Products Description text area, so I established a table row in that vicinity for it to sit in.

    After a bit of experimenting, I inserted all of the code from:
    /includes/modules/sideboxes/product_notifications.php

    into the newly-created table row.


    To simplify things, I made some changes to this newly-added code and moved a couple of files that work with this code, as it was the easiest way to make everything display properly.

    First, I copied these two files from /templates_default/, into /my_template/:
    /includes/templates/template_default/sideboxes/tpl_no_notifications.php
    and
    /includes/templates/template_default/sideboxes/tpl_yes_notifications.php


    Then, I made the following edits to the product_notifications.php code I dropped in:

    The first change...

    This:

    $info_box_contents = array();
    if ($notification_exists == true) {
    require($template->get_template_dir('tpl_yes_notifications.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_yes_notifications.php');
    } else {
    require($template->get_template_dir('tpl_no_notifications.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_no_notifications.php');
    }

    Was changed to:

    $info_box_contents = array();
    if ($notification_exists == true) {
    require(DIR_WS_TEMPLATE . 'sideboxes/tpl_yes_notifications.php');
    } else {
    require(DIR_WS_TEMPLATE . 'sideboxes/tpl_no_notifications.php');
    }

    Since I knew exactly where I put the new copies of these files (see "First, I copied..." above) I thought I'd take the shortest path to these files. It worked, so I left it like that.

    The second change...

    This:

    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

    Was commented-out, thus changed to:

    // require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

    This was done because I was getting an error on this line, so I took the code from:
    /templates/template_default/common/tpl_box_default_single.php

    and added the tables (formatting) code from that file to both:
    /includes/templates/template_default/sideboxes/tpl_no_notifications.php
    and
    /includes/templates/template_default/sideboxes/tpl_yes_notifications.php

    And I'll go over that in the next posting.


    That completes the modifications to:
    /includes/templates/my_template/templates/tpl_product_info_display.php

    The final code that was added to the file looks like this:

    <!-- PRODUCT NOTIFICATION INSERT BEGIN -->
    <tr>
    <td align="left" colspan="2"><?php
    // $Id: product_notifications.php 290 060517 chrx $
    //

    // test if box should show
    $show_product_notifications= false;

    if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
    if ($_SESSION['customer_id']) {
    $check_query = "select count(*) as count
    from " . TABLE_CUSTOMERS_INFO . "
    where customers_info_id = '" . (int)$_SESSION['customer_id'] . "'
    and global_product_notifications = '1'";

    $check = $db->Execute($check_query);

    if ($check->fields['count'] <= 0) {
    $show_product_notifications= true;
    }
    } else {
    $show_product_notifications= true;
    }
    }

    if ($show_product_notifications == true) {
    if (isset($_GET['products_id'])) {
    if ($_SESSION['customer_id']) {
    $check_query = "select count(*) as count
    from " . TABLE_PRODUCTS_NOTIFICATIONS . "
    where products_id = '" . (int)$_GET['products_id'] . "'
    and customers_id = '" . (int)$_SESSION['customer_id'] . "'";

    $check = $db->Execute($check_query);

    $notification_exists = (($check->fields['count'] > 0) ? true : false);
    } else {
    $notification_exists = false;
    }

    $info_box_contents = array();
    if ($notification_exists == true) {
    require(DIR_WS_TEMPLATE . 'sideboxes/tpl_yes_notifications.php');
    } else {
    require(DIR_WS_TEMPLATE . 'sideboxes/tpl_no_notifications.php');
    }
    $title = BOX_HEADING_NOTIFICATIONS;
    $box_id = productnotifications;
    $left_corner = false;
    $right_corner = false;
    $right_arrow = false;
    $title_link = false;
    // require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
    }
    }
    ?>
    </td>
    </tr>
    <!-- PRODUCT NOTIFICATION INSERT END -->

    Now, on to the remaining edits...

    Cheers,
    chrx

  8. #8
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Default Re: Product Notification In Product Info Page!

    Now, on to the rest of the story...

    As I said in the preceding post,

    require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);

    Was commented-out, thus changed to:

    // require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);


    This was done because I was getting an error on this line, so I took the code from:
    /templates/template_default/common/tpl_box_default_single.php

    and added the tables (formatting) code from that file to both:
    /includes/templates/my_template/sideboxes/tpl_no_notifications.php*
    and
    /includes/templates/my_template/sideboxes/tpl_yes_notifications.php*

    (* Please note that I erroneously displayed these two file locations as /includes/templates/template_default/sideboxes/ at the end of the preceding post. Both of these files were first copied from the /template_default/ directory to the /my_template/ directory before being edited. The paths shown above are correct. *)


    Here is how that played out...

    This is the tables code from:
    /templates/template_default/common/tpl_box_default_single.php


    <!--// bof: <?php echo $box_id; ?> //-->
    <table width="<?php echo $column_width; ?>" border="0" cellspacing="0" cellpadding="0" class="singlebox" id="<?php echo str_replace('_', '-', $box_id) . '-table'; ?>">
    <tr class="singleboxheading" id="<?php echo str_replace('_', '-', $box_id) . '-heading-tr'; ?>">
    <!-- Sidebox Header -->
    <td colspan="3" width="100%" class="singleboxheading" id="<?php echo str_replace('_', '-', $box_id) . '-heading-td'; ?>"><?php echo $title; ?></td>
    </tr>
    <tr>
    <!-- Sidebox Contents -->
    <td colspan="3" class="singleboxcontent" id="<?php echo str_replace('_', '-', $box_id . '-content'); ?>">
    <?php echo $content; ?>
    </td>
    </tr>
    <tr>
    <!-- Sidebox Footer -->
    <td colspan="3" height="5px" class="singleboxfooter" id="<?php echo str_replace('_', '-', $box_id) . '-footer'; ?>">
    </td>
    </tr>
    </table>
    <!--// eof: <?php echo $box_id; ?> //-->


    I added this to both tpl_no_notifications.php and tpl_yes_notifications.php to produce the following result (* for brevity, I am showing only the tpl_no_notifications.php sample *):


    //
    $content = "";
    $content .= '<div class="sideBoxContents" align="left">&nbsp;<br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_YES, OTHER_BOX_NOTIFY_YES_ALT) . '</a><br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, zen_get_products_name($_GET['products_id'])) .'</a></div>';
    ?>
    <!-- added from templates/template_default/common/tpl_box_default_single.php -->
    <!--// bof: <?php echo $box_id; ?> //-->
    <table width="<?php echo $column_width; ?>" border="0" cellspacing="0" cellpadding="0" class="singlebox" id="<?php echo str_replace('_', '-', $box_id) . '-table'; ?>">
    <tr class="singleboxheading" id="<?php echo str_replace('_', '-', $box_id) . '-heading-tr'; ?>">
    <!-- Sidebox Header -->
    <td colspan="3" width="100%" class="singleboxheading" id="<?php echo str_replace('_', '-', $box_id) . '-heading-td'; ?>"><?php echo $title; ?></td>
    </tr>
    <tr>
    <!-- Sidebox Contents -->
    <td colspan="3" class="singleboxcontent" id="<?php echo str_replace('_', '-', $box_id . '-content'); ?>">
    <?php echo $content; ?>
    </td>
    </tr>
    <tr>
    <!-- Sidebox Footer -->
    <td colspan="3" height="5px" class="singleboxfooter" id="<?php echo str_replace('_', '-', $box_id) . '-footer'; ?>">
    </td>
    </tr>
    </table>
    <!--// eof: <?php echo $box_id; ?> //-->


    Now, I am not using any of the standard sidebox formatting for this project, so I removed the Header and Footer table data, as well as modifed a bit of the table formatting criteria for this result (* again, I am showing only the tpl_no_notifications.php sample *):


    //
    $content = "";
    $content .= '<div class="sideBoxContents" align="left">&nbsp;<br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BOX_NOTIFY_YES, OTHER_BOX_NOTIFY_YES_ALT) . '</a><br /><a href="' . zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=notify', $request_type) . '">' . sprintf(BOX_NOTIFICATIONS_NOTIFY, zen_get_products_name($_GET['products_id'])) .'</a></div>';
    ?>
    <!-- added from templates/template_default/common/tpl_box_default_single.php -->
    <!--// bof: <?php echo $box_id; ?> //-->
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="singlebox" id="<?php echo str_replace('_', '-', $box_id) . '-table'; ?>">
    <tr>
    <!-- Sidebox Contents -->
    <td colspan="3" class="singleboxcontent" id="<?php echo str_replace('_', '-', $box_id . '-content'); ?>">
    <?php echo $content; ?>
    </td>
    </tr>
    </table>
    <!--// eof: <?php echo $box_id; ?> //-->


    I sent this up to the server, and there it was! The only thing left to figure out was how to get rid of the border around the whole thing, until I thought to look at the stylesheet in:
    /includes/templates/my_template/css/stylesheet.css

    Referring to class="singleboxcontent" in the tables code from the tpl_box_default_single.php file,
    I changed this:

    }
    .leftbox, .rightbox, .centerbox, .singlebox {
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 11px;
    background: #ffffff;
    border: 1px solid #9a9a9a;
    margin-bottom: 15px;
    }


    To this:

    }
    .leftbox, .rightbox, .centerbox, .singlebox {
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 11px;
    background: #ffffff;
    border: 0px solid #ffffff;
    margin-bottom: 15px;
    }

    Rounding it out were customized "Notify Me" and "Don't Notify Me" graphics, and that pretty much took care of it! I now have fully-functioning Product Notification inside the product_info page. And you can too.

    Cheers, and thanks to Ajeh for the pointers!
    chrx

  9. #9
    Join Date
    Aug 2005
    Location
    SF Bay Area, California, USA
    Posts
    89
    Plugin Contributions
    0

    Default Re: Product Notification In Product Info Page!

    One last note:

    The "sideboxes/product_notifications.php" setting does not have to be turned ON in the Admin/Tools/Layout Boxes Controller for this to work.

    See it at:
    http://www.maximummotorsports.com/

    Cheers,
    chrx

  10. #10
    Join Date
    Nov 2006
    Posts
    512
    Plugin Contributions
    0

    Default Re: Product Notification In Product Info Page?

    I am using ZC 1.3.7 and wanted the same thing. I copied the entire product_notifications sidebox page and pasted it into the <!--bof Add to Cart Box --> on the tpl_product_info_display page :

    it seems to work ok. Please post if there is a better way.

    PHP Code:
    <?php
    /**
     * product_notifications sidebox - displays a box inviting the customer to sign up for notifications of updates to current product
     *
     * @package templateSystem
     * @copyright Copyright 2003-2005 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: product_notifications.php 2993 2006-02-08 07:14:52Z birdbrain $
     */

    // test if box should show
      
    $show_product_notifications false;

      if (isset(
    $_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
        if (isset(
    $_SESSION['customer_id'])) {
          
    $check_query "select count(*) as count
                          from " 
    TABLE_CUSTOMERS_INFO "
                          where customers_info_id = '" 
    . (int)$_SESSION['customer_id'] . "'
                          and global_product_notifications = '1'"
    ;

          
    $check $db->Execute($check_query);

          if (
    $check->fields['count'] <= 0) {
            
    $show_product_notificationstrue;
          }
        } else {
          
    $show_product_notificationstrue;
        }
      }

    if (
    $show_product_notifications == true) {
      if (isset(
    $_GET['products_id'])) {
        if (isset(
    $_SESSION['customer_id'])) {
          
    $check_query "select count(*) as count
                          from " 
    TABLE_PRODUCTS_NOTIFICATIONS "
                          where products_id = '" 
    . (int)$_GET['products_id'] . "'
                          and customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'";

          
    $check $db->Execute($check_query);

          
    $notification_exists = (($check->fields['count'] > 0) ? true false);
        } else {
          
    $notification_exists false;
        }

        if (
    $notification_exists == true) {
          require(
    $template->get_template_dir('tpl_yes_notifications.php',DIR_WS_TEMPLATE$current_page_base,'sideboxes'). '/tpl_yes_notifications.php');
        } else {
          require(
    $template->get_template_dir('tpl_no_notifications.php',DIR_WS_TEMPLATE$current_page_base,'sideboxes'). '/tpl_no_notifications.php');
        }
        
    $title =  BOX_HEADING_NOTIFICATIONS;
        
    $box_id 'productnotifications';
        
    $title_link false;
        require(
    $template->get_template_dir($column_box_defaultDIR_WS_TEMPLATE$current_page_base,'common') . '/' $column_box_default);
      }
    }
    ?>

 

 

Similar Threads

  1. Replies: 0
    Last Post: 21 Mar 2012, 09:20 PM
  2. Issues with Product info page: my product image is overlapping the product name, etc
    By wmorris in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 4 May 2011, 06:30 PM
  3. remove View or change my product notification list from account info page
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 May 2010, 04:54 PM
  4. Replies: 0
    Last Post: 18 Dec 2009, 01:07 PM

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