Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Recently Viewed Products(sales optimized)


b00

Recommended Posts

Hello Chris @@ringo667,

 

Please try to add the following snippet at the beginning of product_info.php:

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

  $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  $product_check = tep_db_fetch_array($product_check_query);

  // begin recently_viewed
// Creates/updates a session variable -- a string of products IDs separated by commas
//    IDs are in order newest -> oldest
  $recently_viewed_string = '';
  if ($product_check['total'] > 0) { //We don't want to add products that don't exist/are not available

    if (!tep_session_is_registered('recently_viewed')) {
      tep_session_register('recently_viewed');
    } else {
      $recently_viewed_string = $_SESSION['recently_viewed'];
    }

// Deal with sessions created by the previous version
    if (substr_count ($recently_viewed_string, ';') > 0) {
      $_SESSION['recently_viewed'] = '';
      $recently_viewed_string = '';
    }
  
// We only want a product to display once, so check that the product is not already in the session variable
    $products_id = (int) $_GET['products_id'];
    if ($recently_viewed_string == '') { // No other products
      $recently_viewed_string = (string) $products_id; // So set the variable to the current products ID
    } else {
      $recently_viewed_array = explode (',', $recently_viewed_string);
      if (!in_array ($products_id, $recently_viewed_array) ) {
        $recently_viewed_string = $products_id . ',' . $recently_viewed_string; //Add the products ID to the beginning of the variable
      }
    }

    $_SESSION['recently_viewed'] = $recently_viewed_string;
    
  } //if ($product_check['total']
// end recently_viewed

  require(DIR_WS_INCLUDES . 'template_top.php');

Let me know if this works. I'll then update the add-on package.

 

regards

Rainer

Link to comment
Share on other sites

i have installed all modules....

 

Hi Chris,

 

your shop is based on an earlier version of bootstrap, not on bootstrap-gold. To get raiwas addon into your product_info you must add the appropriate hook to that file:

 

  <div class="row">

    <?php echo $oscTemplate->getContent('product_info'); ?>

  </div>

 

J.J.

Link to comment
Share on other sites

@@De Dokta,

 

Thank's, didn't know that the content module wasn't included in older versions.:-)

Link to comment
Share on other sites

Thanks a Million, now the Box shows the Products.

 

but i have find two Errors.

 

When i switch the price off it happens a Database Error

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 'from products_description pd, products p ' at line 1

 select p.products_id, from products_description pd, products p left join specials s on p.products_id = s.products_id where p.products_id in (1651,1887,54,546,1928,1725) and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '2' 

[TEP STOP]

The Links on /recently_viewed.php do not working.

/-p-.html?slave_id=1928
Link to comment
Share on other sites

Hello Chris @@ringo667,

 

For the sql error, yes there is a bug in the query, please apply the following changes:

 

includes/boxes/bm_recently_viewed.php:

find:

      	$products_query = "  select p.products_id,";
      		
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        $products_query .= "        p.products_tax_class_id,
        													  p.products_price";
      	}

Change to:

      	$products_query = "select ";
      		
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_BOXES_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        	$products_query .= "      p.products_tax_class_id,
        													  p.products_price,";
      	}
      	$products_query .= "  			p.products_id";

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

find:

      	$products_query = "  select p.products_id,";
      		
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        $products_query .= "        p.products_tax_class_id,
        													  p.products_price";
      	}

change to:

      	$products_query = "select ";
      		
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_CONTENT_INDEX_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        	$products_query .= "      p.products_tax_class_id,
        													  p.products_price,";
      	}
      	$products_query .= "  			p.products_id";

In: includes/modules/content/product_info/cm_pi_recently_viewed.php:

find:

      	$products_query = "  select p.products_id,";
      		
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        $products_query .= "        p.products_tax_class_id,
        													  p.products_price";
      	}

change to:

      	$products_query = "select ";
      		
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_DESCRIPTION == 'True')
        	$products_query .= "     pd.products_description,";
        
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_IMAGE == 'True')
          $products_query .= "      p.products_image,";
                                       
        if (MODULE_CONTENT_PRODUCT_INFO_RECENTLY_VIEWED_SHOW_PRICE == 'True') {
        	$products_query .= "      p.products_tax_class_id,
        													  p.products_price,";
      	}
      	$products_query .= "  			p.products_id";

This should work now for all combinations. Please confirm and I'll upload the fix.

 

For the non working link in recently_viewed.php:

Your link is not standard. You may have modified your product_listing.php. Looks like master products add-on.

So you should apply the same changes you applied in index.php, new_products.php and specials.php to the recently_viewed.php file.

It uses the standard includes/modules/product_listing.php

 

regards

Rainer

Link to comment
Share on other sites

@@raiwa

 

Hi

 

Just tested your BS version on BS gold - works really great! :rolleyes:

Two small issues: It would be helpful, to add SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT to content\product_info\cm_pi_recently_viewed.php and to modules\content\index\cm_recently_viewed.php to prevent problems with images of different sizes.

 $recently_viewed_content .= tep_image (DIR_WS_IMAGES . $products_data[$products_id]['image'], $products_data[$products_id]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT . 'hspace="2" vspace="3"');

It also would be useful to add the equal-height tag to modules\content\product_info\cm_pi_recently_viewed.php:

 $recently_viewed_content .= '    <div class="thumbnail equal-height">';

J.J.

 

Link to comment
Share on other sites

@@raiwa

 

Hi

 

Just tested your BS version on BS gold - works really great! :rolleyes:

Two small issues: It would be helpful, to add SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT to content\product_info\cm_pi_recently_viewed.php and to modules\content\index\cm_recently_viewed.php to prevent problems with images of different sizes.

 $recently_viewed_content .= tep_image (DIR_WS_IMAGES . $products_data[$products_id]['image'], $products_data[$products_id]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT . 'hspace="2" vspace="3"');

It also would be useful to add the equal-height tag to modules\content\product_info\cm_pi_recently_viewed.php:

 $recently_viewed_content .= '    <div class="thumbnail equal-height">';

J.J.

 

Thank you, will have a try and include it in the next update.

Link to comment
Share on other sites

@@De Dokta,

 

I had a look on your modifications and yes, the image sizes are missing. I'm using OPI image thumbnail and had this stripped off.

However, already updating I think "hspace="2" vspace="3" is obsolete and can be stripped off.

So I would suggest this:

$recently_viewed_content .= tep_image (DIR_WS_IMAGES . $products_data[$products_id]['image'], $products_data[$products_id]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT');

For the equal height tag, I'm not sure what to do. It could produce a conflict if more than one module on the same page uses it.

For example: if the equal height tag will be added to the also purchased product module and uses less content than the recently viewed boxes, all box heights will be adjusted to the biggest on the page. This happens already if we use equal height in the index recently viewed module. (new products and specials modules uses equal height too).

 

So may be the best would be to add a configuration entry for the equal height div. Like this the user can choose.

 

What is your opinion??

 

regards

Rainer

Link to comment
Share on other sites

 

The Links on /recently_viewed.php do not working.

/-p-.html?slave_id=1928

Hello Chris @@ringo667,

 

Sorry I was wrong for the links. The link should be set up like this: "product_info.php?products_id=1928" and if you are using SEO URLs it should be converted to:"yourproductsname-p-1928.html".

If it shows like you say, there is something modified in that line of your module:

      $optional_rel_prods_content .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">';

Or there is something related with your SEO URL add-on. You could try to switch your SEO URL temporary off to see if it works correct with standard URLs.

 

I tested the module  without SEO URLs, with Ultimate SEO URLs 5 and with Chemos SEO URLs 2.2. It works all correct.

 

Sorry for the confusion

Rainer

Edited by raiwa
Link to comment
Share on other sites

I had a look on your modifications and yes, the image sizes are missing. I'm using OPI image thumbnail and had this stripped off.

However, already updating I think "hspace="2" vspace="3" is obsolete and can be stripped off.

So I would suggest this:

$recently_viewed_content .= tep_image (DIR_WS_IMAGES . $products_data[$products_id]['image'], $products_data[$products_id]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT');
For the equal height tag, I'm not sure what to do. It could produce a conflict if more than one module on the same page uses it.

For example: if the equal height tag will be added to the also purchased product module and uses less content than the recently viewed boxes, all box heights will be adjusted to the biggest on the page. This happens already if we use equal height in the index recently viewed module. (new products and specials modules uses equal height too).

 

So may be the best would be to add a configuration entry for the equal height div. Like this the user can choose.

 

@@raiwa

You are right, hspace and vspace are obsolete. I've overseen that.

 

Regarding the equal height tag I'm not sure what the best way is.  As far as I know none of the modules on product info uses by default the equal height script. So there would be no conflict. But on the index page at least the new products module uses the script and the result looked very strange, when I added it also to the recently_viewed module. For that I added a setting in the user.css. Perhaps it would be possible to add a height setting to your module(s)?

 

BTW: Chris' (ringo667) problem had nothing to do with your add-on. He uses the master/slave addon and for that reason the $listing_sql in recently_viewed.php simply needed an additional  "p.products_master, p.products_master_status" :- . We have resolved that in the German forum.......

 

J.J.

 

Link to comment
Share on other sites

@@raiwa

 

Hi

 

Now trying to install this addon, however for the life of me I can't find

 

In: [catalog/]login.php

Find:
if ( tep_session_is_registered('comments') ) {
  tep_session_unregister('comments');
}

 

Im using the latest download from burts github.BS234

 

I think I must be thicker than two short planks.

 

Can you point me in the right direction please.

 

Many thanks

 

Grandpa

Link to comment
Share on other sites

@@raiwa

 

In: [catalog/]login.php

Find:

if ( tep_session_is_registered('comments') ) {

  tep_session_unregister('comments');

}

Hello John @@grandpaj,

 

Yes, this is in logoff.php, sorry and thank you for the report.

I'll fix it in the next update.

Link to comment
Share on other sites

thanx you. i have insalled the new Version. Now it works.

 

Another question:

how can i show the prices with the German Tax Info?

http://addons.oscommerce.com/info/8160

Link to comment
Share on other sites

@@raiwa

 

Regarding the equal height tag I'm not sure what the best way is.  As far as I know none of the modules on product info uses by default the equal height script. So there would be no conflict. But on the index page at least the new products module uses the script and the result looked very strange, when I added it also to the recently_viewed module. For that I added a setting in the user.css. Perhaps it would be possible to add a height setting to your module(s)?

 

 

@@De Dokta,

 

The also purchased module does not use it yet, but it may be added in the future. I mentioned this also referring to my other module "optional related products" where I would like to add the same solution, so if someone uses both modules with different contents, the same problem appears.

 

My suggestion: add both possibilities, "equal height", " fixed height" (with value field) and "none" (like it is now) to configuration, so the user can choose what best fits his needs.??

Edited by raiwa
Link to comment
Share on other sites

Hi

 

I installed this Contrib in a brandnew 234Gold - checked it twice - and got an error:

Fatal error: Call to undefined function tep_version_readonly() in /usr/www/users/xx/catalog/admin/modules.php(244) : eval()'d code on line 1

in modules -> boxes

 

What went wrong - i can't find it?

 

Thank you

Oliver

Edited by chilinotes
Link to comment
Share on other sites

Fatal error: Call to undefined function tep_version_readonly() in /usr/www/users/xx/catalog/admin/modules.php(244) : eval()'d code on line 1

in modules -> boxes

 

Hello Oliver @@chilinotes,

 

In: includes/functions/recently_viewed.php

 

Add at the end:

  if(!function_exists('tep_version_readonly')) {
        function tep_version_readonly($value){
          $version_text = '<br>Version ' . $value;
          return $version_text;
        }
  }

In the 3 modules:

includes/modules/boxes/bm_rently_viewed.php

includes/modules/content/index/cm_i_rently_viewed.php

includes/modules/content/product_info/cm_pi_rently_viewed.php

 

Below the lines which begin with:

            $this->title = MODULE_...............
      $this->description = MODULE_................

Add:

      require_once(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . 'recently_viewed.php');

I'll upload the fix soon. Thank you for the report

 

Kind regards

Rainer

Edited by raiwa
Link to comment
Share on other sites

  • 3 weeks later...

@@raiwa

Hi

 

Just installed this addon, looks great.

I thought I had followed every instruction, however the only problem I have is that when the Recently Viewed page is showing, if I click on either List/Grid I get returned to the index page.

I have followed  Admin > Modules > Header Tags:
Install Module: Recently Viewed and installed it.

So Ive done something wrong.

look forward to your comments.

 

Many thanks

Grandpa

Edited by grandpaj
Link to comment
Share on other sites

Hello John @@grandpaj,

 

Instructions:

IMPORTANT:  If you are using Header Tag Grid List Javascript Module, include the Page: recently_viewed.php

 

Admin => Modules => Header Tags => Grid List Javascript (jQuery) => Pages => select recently_viewed.php

Link to comment
Share on other sites

@@raiwa

 

Hi

 

Thanks for that. I just hadn't gone quite "deep enough" in

Admin => Modules => Header Tags => Grid List Javascript (jQuery) => Pages => select recently_viewed.php

 

Many thanks

 

Kind regards

Grandpa

Link to comment
Share on other sites

Hi Rainer

 

Me again.

 

Just would like to do a wee mod, and that is to move the "See More" button on the Product Information page from right next the the text "Recently Viewed" to the right hand side of the page. I suspect the file to change is cm_pi_recently_viewed.php line 162.

Can you tell me please what I would need to change. etc

 

Also, if Im a customer and have viewed say 20 products, is there anyway I can "clear" the "Viewed Products" page

or does that start again when a new session starts.

 

Many thanks

Grandpa

Edited by grandpaj
Link to comment
Share on other sites

Hello John @@grandpaj,

 

Yes the button is in the file you say.

To move it you can wrap around the button:

<p class="text-right">Right aligned text.</p>

Or try to add the pull-right class:

<div class="pull-right">...</div>

Have a look here:

http://getbootstrap.com/css/#type

 

and yes, recently viewed products are stored in the session and expires like the shopping cart content for example.

 

regards

Rainer

Edited by raiwa
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...