Jump to content
b00

[Contribution] Recently Viewed Products(sales optimized)

Recommended Posts

Hello,

I have your most recent version installed on Frozen and get this error with php 7.2 :

Warning: count(): Parameter must be an array or an object that implements Countable in /xxx/xx/xx/xx/catalog/includes/modules/content/shopping_cart/cm_sc_continue_recently_viewed.php on line 66
Line 65-69 are:

           $back = sizeof($navigation->path)-2;
            $count = count($products);
            if( isset($products[$count-1]['id']) ) {
                $continueButtonId = tep_get_product_path(str_replace(strstr($products[$count-1]['id'], '{'), '', $products[$count-1]['id']));
            }

Any ideas would be greatly appreciated.

Barbara

Share this post


Link to post
Share on other sites

Updated with the above PHP 7.2 warning error fix:

 Version 4.6.2 BS

                Changes:        
         - Fixed PHP 7.2 warning error in cm_sc_continue_recently_viewed.php shopping cart module. Thanks to @lucsangel for the report

https://apps.oscommerce.com/z7iA8&recently-viewed-products-bs

Share this post


Link to post
Share on other sites

hi Rainer,

This is a small modification to this addon for anyone who wants to use it,.. and if you see value in it, you could add it to an update release.

The mod is designed to only show the “See More” button if the number of recently viewed products exceeds the content limit of recently viewed products for each module.

For example: if a customer viewed 4 or less products and the content limit is set to 4 recently viewed products, then it does not makes sense to have them see and click on a "See More" button that takes them to a Recently Viewed Products page containing the same 4 or less products that were listed on whatever page they were on.

So, here are the changes and I’m only going to use the product_info page Recently Viewed module in this sample. This works in BS Edge.

/includes/modules/content/index/cm_i_recently_viewed.php

1)      FIND this code:

        // Set up the product data string in order by $recently_viewed_array
        if ($num_products > 0) { // Show only if we still have products in the array

ADD just ABOVE it:

        // this will show/hide the "See More" button
        $rv_btn = 'style="display:none;"';
        $rv_number_viewed = substr_count($recently_viewed_string, ",") + 1; 
        if ($rv_number_viewed > MODULE_CONTENT_INDEX_RECENTLY_VIEWED_CONTENT_LIMIT) {
            $rv_btn = 'style="display:inline;"';
        }

 

2)      FIND this code:

        	$recently_viewed_content .= '<h3 class="h3"><span itemprop="name">' . MODULE_CONTENT_INDEX_RECENTLY_VIEWED_TITLE . '</span>' . ((MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_MORE_BUTTON == 'True')? '  <a href="' . tep_href_link('recently_viewed.php') . '" class="btn btn-default btn-sm">' . MODULE_CONTENT_INDEX_RECENTLY_VIEWED_IMAGE_BUTTON_SEE_MORE . '  <span class="fa fa-angle-right"></span></a>' : '' ) . '</h3>';

REPLACE it with this:

        	$recently_viewed_content .= '<h3><span itemprop="name">' . MODULE_CONTENT_INDEX_RECENTLY_VIEWED_TITLE . '</span>' . ((MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_MORE_BUTTON == 'True')? '&nbsp;&nbsp;<span ' . $rv_btn . '>' . tep_draw_button(MODULE_CONTENT_INDEX_RECENTLY_VIEWED_IMAGE_BUTTON_SEE_MORE, 'glyphicon glyphicon-triangle-right', tep_href_link('recently_viewed.php'), 'primary', null, 'btn-default btn-sm') . '</span>':'') . '</h3>';

 


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Share this post


Link to post
Share on other sites

@raiwa - Is there a module available to put Recently Viewed in the navigation bar? 

I'm trying to minimize the use of infoboxes and make the pages less cluttered. 

I've tried the header module, but just can't get happy with how it looks.  A link in the navigation bar would be better. :)

Thank You!

- Andrea

 

Share this post


Link to post
Share on other sites

Hello Andrea @puggybelle,

Navbar module is not available yet. I'll see if I find some time to add it. I believe it wouldn't be complicate to use the header module's coding and create the navbar module. Maybe you can try.

Best regards
Rainer

Share this post


Link to post
Share on other sites

Hello all,

I'm using the non BS (2.3.4) version and all is well.... except when the rare visitor happens to enter the site directly using https://www.domain.com/recently_viewed.php.

the result is a soft 404 page

Recently Viewed
Products you have recently viewed
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') and p.products_id = pd.products_id and pd.language_id = '1'' at line 1

select count(*) as total from products p left join manufacturers m on (p.manufacturers_id = m.manufacturers_id), products_description pd where p.products_status = '1' and p.products_id IN () and p.products_id = pd.products_id and pd.language_id = '1'

[TEP STOP]

I'm pretty sure here is what needs sorting

  $viewed = implode(",", array_unique($navigation->products));

  if (sizeof($viewed) == 0) {
    tep_redirect(tep_href_link(FILENAME_PRODUCTS_NEW));
  }

here is the entire recently_viewed.php

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2013 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_RECENTLY_VIEWED);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_RECENTLY_VIEWED));
  
  $viewed = implode(",", array_unique($navigation->products));

  if (sizeof($viewed) == 0) {
    tep_redirect(tep_href_link(FILENAME_PRODUCTS_NEW));
  }

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<h1><?php echo HEADING_TITLE; ?></h1>
<h2><?php echo HEADING_SUBTITLE; ?></h2>

<div class="contentContainer">
  <div class="contentText">

<?php
  $products_new_array = array();

  $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id IN (" . $viewed . ") and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' ORDER BY FIELD(p.products_id, " . $viewed . ")";

  $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

  if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

    <div>
      <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>

      <span><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_VIEWED); ?></span>
    </div>

    <br />

<?php
  }
?>

<?php
  if ($products_new_split->number_of_rows > 0) {
?>

    <table border="0" width="100%" cellspacing="2" cellpadding="2">

<?php
    $products_new_query = tep_db_query($products_new_split->sql_query);
    while ($products_new = tep_db_fetch_array($products_new_query)) {
      if ($new_price = tep_get_products_special_price($products_new['products_id'])) {
        $products_price = '<del>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>';
      } else {
        $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id']));
      }

// PRODUCTS SHIP FREE START
			$freeship_str = '';
	if(tep_products_ship_free_check($products_new['products_id']))
			      $freeship_str = '<span class="freeShipSm">(' . TEXT_PRODUCT_SHIPS_FREE . ')</span>';
// PRODUCTS SHIP FREE END
// added to below for Products Ship Free:  . ' ' . $freeship_str
?>
      <tr>
        <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>
        <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id']) . '"><strong><u>' . $products_new['products_name'] . '</u></strong></a><br />' . TEXT_DATE_ADDED . ' ' . tep_date_long($products_new['products_date_added']) . '<br />' . TEXT_MANUFACTURER . ' ' . $products_new['manufacturers_name'] . '<br /><br />' . TEXT_PRICE . ' ' . $products_price . ' ' . $freeship_str; ?></td>
        <!--<td align="right" valign="middle" class="smallText"><?php // echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id'])); ?></td>-->

<!--// BOF: MOD - EASY CALL FOR PRICE 2.3.1v1.1-->
        <td align="right" valign="middle" class="prixST">
        <?php 
        $products_price_tmp =  preg_match_all('/([\d]+)/', $products_price, $match);
        if ((int)$products_price_tmp > 0){        
            echo tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', tep_href_link(FILENAME_RECENTLY_VIEWED, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id'])); 
        } else echo $products_price ;        
        ?></td>
<!--// EOF: MOD - EASY CALL FOR PRICE 2.3.1v1.1-->

      </tr>
<?php
    }
?>

    </table>

<?php
  } else {
?>

    <div>
      <?php echo TEXT_NO_VIEWED_PRODUCTS; ?>
    </div>

<?php
  }

  if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>

    <br />

    <div>
      <span style="float: right;"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></span>

      <span><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_VIEWED); ?></span>
    </div>

<?php
  }
?>

  </div>
</div>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

any assistance appreciated.

Dave


-Dave

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×