Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Recently Viewed Products(sales optimized)


b00

Recommended Posts

Uploaded update:

Version 4.6.1. BS

Changes:        
         - Updated PHP 7.2 deprecated each() function in recently_viewed.php

Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
Share on other sites

@lucsangel Hello Barbara,

Please change line 66 to:

	    	$count = isset($products)? count($products) : 0;

 

Edited by raiwa
Link to comment
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

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 2 months later...

@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

 

Link to comment
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

Link to comment
Share on other sites

  • 5 weeks later...

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

Link to comment
Share on other sites

  • 4 months later...

Updated for Phoenix 1.0.2.0.

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

Compatibility:
Phoenix 1.0.2.x
PHP: 7.0-7.3
*********************************************************************************************************************
This version has not been tested with earlier Phoenix versions.
You will need to apply at least the following database update to use it with Phoenix 1.0.0.x or 1.0.1.x.:
https://pastebin.com/Ed8B6nuT
You may also need to update custom.css
*********************************************************************************************************************

Changes:        
         - updated to Phoenix 1.0.2.x
         - replaced ht-module with sidewide hook
         - updated coding to match Phoenix 1.0.2.0 product listings and config entries
         - simplified modules and removed config entries to show always product name, image and price
         - simplified description length limit

 

Link to comment
Share on other sites

Upddated to Version 5.0.1 Phoenix

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

Compatibility:
Phoenix 1.0.2.x
PHP: 7.0-7.3
*********************************************************************************************************************
This version has not been tested with earlier Phoenix versions.
You will need to apply at least the following database update to use it with Phoenix 1.0.0.x or 1.0.1.x.:
https://pastebin.com/Ed8B6nuT
You may also need to update custom.css
*********************************************************************************************************************

Changes:        

         - modified "See More" button to show only if more recently products have been visited than number of recently products shown in module.
Thanks to @Demitry for the suggestion
         - readded missing truncate text function in cm_sc_continue_recently_viewed.php shopping cart module
         - removed obsolete truncate text functions in box module

 

Link to comment
Share on other sites

  • 3 months later...

Hi @raiwa,

Could it be that this is no longer working with phoenix? It looks like Gary has changed the product_listing module in v1.0.3.0. I have no more Images in the listing.

The Box works, but the Imagepath in the listing is empty. Only "images/". Can you confirm this, or is it a bug at my testshop ?

Regards,
Denzel.

Link to comment
Share on other sites

21 minutes ago, Denzel said:

Hi @raiwa,

Could it be that this is no longer working with phoenix? It looks like Gary has changed the product_listing module in v1.0.3.0. I have no more Images in the listing.

The Box works, but the Imagepath in the listing is empty. Only "images/". Can you confirm this, or is it a bug at my testshop ?

Regards,
Denzel.

Recently Viewed Products (sales optimized) for OSCOM CE Phoenix

Compatibility:
Phoenix 1.0.2.x
PHP: 7.0-7.3

Not yet updated to Phoenix 1.0.3.x. It should not be too complicate if you compare with the core product module.

EDIT: Just checked and the mayor product listing update was introduced in Phoenix 1.0.2.0  , so there must be another issue.

I'll test with 1.0.3.0 when I'll find some time.

Edited by raiwa
Link to comment
Share on other sites

Just checked with Phoenix 1.0.3.0 and all works fine. Must be something with your store.

Link to comment
Share on other sites

I got it: In 1.0.3.0 in admin->modules->product listing the Image option is empty by default. As the function is marked as defunct, I don't care about.
I've changed it to "1" and voilà: Images appears 😎

image.thumb.png.47e64e6333e5537e52322af4cc33e5c8.png

If burt has planned to delete the function, this must be adjusted somewhere in the contrib ...

Regards,
Denzel.

Link to comment
Share on other sites

  • 1 month later...

Upddated to Version 5.0.2 Phoenix, tested with Phoenix 1.0.4.3

Recently Viewed Products Phoenix

Changes:        
         - removed deprecated "Product Image" configuration setting
         - updated database query in recently_viewed.php

 

Link to comment
Share on other sites

  • 4 weeks later...
On 1/20/2020 at 11:02 PM, raiwa said:

Upddated to Version 5.0.2 Phoenix, tested with Phoenix 1.0.4.3

Recently Viewed Products Phoenix

Changes:        
         - removed deprecated "Product Image" configuration setting
         - updated database query in recently_viewed.php

 

Hi , Thank you for this wonderful addon;

I use Oscommerce 1.0.5.0 Phoenix with multiple languages- English, German, Spanish

I face a issue the products shown in the recently viewed are in all 3 languages together..

When I view the catalog in English----The recently viewed addon shows a product in english, german and spanish in 3 separate boxes of the row.

Please help on how to fix it;

Regds./

radhavallabh

Edited by radhavallabh
Link to comment
Share on other sites

23 hours ago, radhavallabh said:

Hi , Thank you for this wonderful addon;

I use Oscommerce 1.0.5.0 Phoenix with multiple languages- English, German, Spanish

I face a issue the products shown in the recently viewed are in all 3 languages together..

When I view the catalog in English----The recently viewed addon shows a product in english, german and spanish in 3 separate boxes of the row.

Please help on how to fix it;

Regds./

radhavallabh

Hello,

I checked on my multilanguage test store and all shows correct.

Can you please post a screenshot and/or PM the link to the store.

rgds
Rainer

Link to comment
Share on other sites

18 hours ago, raiwa said:

Hello,

I checked on my multilanguage test store and all shows correct.

Can you please post a screenshot and/or PM the link to the store.

rgds
Rainer

I am currently installing on Xampp Server..

Attaching a screenshot of it.. Hope to fix it...

Thank you in advance for your valuable help and reply;

Regds./

radhavallabh

Screenshot_2020-02-20 Heavenly Fauna Wool Winter Radha Krishna Dress.png

Link to comment
Share on other sites

Please check if you have the same problem in your new products module.

The recently products module is correct coded for multilanguage store. It must be something with your store setup.

Just to be sure, you didn't change anything in the recently products module?

Link to comment
Share on other sites

55 minutes ago, raiwa said:

Please check if you have the same problem in your new products module.

The recently products module is correct coded for multilanguage store. It must be something with your store setup.

Just to be sure, you didn't change anything in the recently products module?

Hi; The New Products module works perfectly;

I did not make any change to the Recently Viewed module it is same core install as on the latest version.😟

Attaching screenshot of the New Products.

Screenshot_2020-02-20 Index Page Title Radha Krishna Spiritual Store.png

Link to comment
Share on other sites

Quote

it is same core install as on the latest version

Which versions are we talking about: Phoenix and recently viewed?

I can't research further on this without access to your store.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...