Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Recently Viewed Products(sales optimized)


b00

Recommended Posts

Thanks, that did the trick! It is working perfectly now. I know I'm not a PHP guru either, but why was this change sufficient? I mean, what happened when I placed the brackets around the piece of code? Just curious...

 

It made the SQL query syntax MySQL5 compatible. You must be on a higher version of MySQL then this contribution was originally written on. The brackets are just new syntax for versions of MySQL5 and higher.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

Hi, I have just installed this contribution on cre loaded 6.15 and now have it working the way I want it, so thanks for the contribution. I had to make quite a lot of changes, see below.

 

1.You state in the recently_viewed.txt, "All this is without slowing down the product info page (as no extra database queries are required there)." This is not true. The way it is written in includes/boxes/recently_viewed.php you use the line:-

 

tep_get_products_name($recent),0,$recently_viewed_box_max_characters_per_line)

 

to get the product name. This function does a select on the product table and it does it for each 'recently viewed' product in the array. If you have 5 recently viewed products, thats 5 extra reads to the db.

 

How I got around this.

 

When you build up the string of 'recently viewed' products in the products_info program, instead of storing just the product_id, store whatever you want. In my case, product_image and product_name. Now when you go to build the 'recently viewed' box you already have the info so do not have to go back to the db. Cool eh.

 

I can't show the exact code as the files are structured slightly different in cre loaded.

 

2.The other main change I made was to show the 'recently viewed' products in a box directly under the product where it can be easily seen by the customer.

 

3.I made it so that it does not display the product you are viewing in the 'recently viewed' box as that seemed a bit pointless and used an image with the product name as the 'title' instead of a text link.

 

I am very pleased with the result and am greatful for the contribution for the code. Thanks again.

 

You can see the 'recently viewed' box working at Sexotic Toys Just go to a product and then visit another. You will see the 'recently visited' box just below the main product details. Oh, it's a adult site so if you are under 18 please do not follow the link.

 

Any comments about the site would be appreciated. Its still being developed (as at jan 25 2008) so please take that into consideration.

 

Cheers

Webmaster www.SexoticToys.co.uk

Link to comment
Share on other sites

Hi, I have just installed this contribution on cre loaded 6.15 and now have it working the way I want it, so thanks for the contribution. I had to make quite a lot of changes, see below...

You can see the 'recently viewed' box working at Sexotic Toys Just go to a product and then visit another. You will see the 'recently visited' box just below the main product details. Oh, it's a adult site so if you are under 18 please do not follow the link.

Any comments about the site would be appreciated. Its still being developed (as at jan 25 2008) so please take that into consideration...

Nice work

:>)

Link to comment
Share on other sites

  • 1 month later...
Hi, I have just installed this contribution on cre loaded 6.15 and now have it working the way I want it, so thanks for the contribution. I had to make quite a lot of changes, see below.

 

1.You state in the recently_viewed.txt, "All this is without slowing down the product info page (as no extra database queries are required there)." This is not true. The way it is written in includes/boxes/recently_viewed.php you use the line:-

 

tep_get_products_name($recent),0,$recently_viewed_box_max_characters_per_line)

 

to get the product name. This function does a select on the product table and it does it for each 'recently viewed' product in the array. If you have 5 recently viewed products, thats 5 extra reads to the db.

 

How I got around this.

 

When you build up the string of 'recently viewed' products in the products_info program, instead of storing just the product_id, store whatever you want. In my case, product_image and product_name. Now when you go to build the 'recently viewed' box you already have the info so do not have to go back to the db. Cool eh.

 

I can't show the exact code as the files are structured slightly different in cre loaded.

 

2.The other main change I made was to show the 'recently viewed' products in a box directly under the product where it can be easily seen by the customer.

 

3.I made it so that it does not display the product you are viewing in the 'recently viewed' box as that seemed a bit pointless and used an image with the product name as the 'title' instead of a text link.

....

Cheers

 

Nice work, do you mind sharing the code with us please?

Link to comment
Share on other sites

  • 2 weeks later...
Hi, I have just installed this contribution on cre loaded 6.15 and now have it working the way I want it, so thanks for the contribution. I had to make quite a lot of changes, see below.

 

... <ZAP> ...

 

Any comments about the site would be appreciated. Its still being developed (as at jan 25 2008) so please take that into consideration.

 

Cheers

 

@ englishchrissy,

 

From what I see on your website, you seem to have created just the adjustments I was looking for in this contrib. I do however not have the coding skills to make all adjustments myself. Could you please post some form of code snippets for us here, shining some more light on how you got this to work in your CRE site? I've got an heavily modified OSCMax as the base of the site I'm working on (basically ripped out the entire STS to get more stock OSC contribs working).

 

@ b00 (and englishchrissy, since you might have found this error as well):

 

I think I might have found a (minor) bug. Please other users (e.g. englishchrissy), could you check if this also happens to you when the contrib is added? Since I use a heavily modified OSCMax catalog, it might just be related to another contrib / setting of mine:

 

If your users surf to a products using the standard menu interface (e.g. category -> sub-category -> product-listing -> product), then the product is added nicely into you "recently visited". The link to the product works, and the "see more" gives a nice overview of all recently visited products. This is OK and how it should work.

If however your users surf to a product via the shopping_cart.php file (by clicking on a product that has been added to their cart), they are not send to the product page, but to the product page + selected attributes as how the product was added into the shopping cart (if the product has options / attributes). This is then recorded as a "recently viewed" product. This then results in an SQL error when you then try to open the recently_viewed.php page via the "See more" button (an SQL error appears related to the "productID{optionID}optionValue{optionID}optionValue" (which makes sense, in a way).

 

From what I can conclude, this is related to how the "recently_viewed.php" page queries the db for recently viewed products or how they are entered into the db from the "product_info" page. They do appear in the infobox, with a correct name and are "clickable" and the link brings you to the correct product page + options.

 

I must add that I've got the SEO urls installed and set to cPath, which might be related I think (remember, I'm not a real coder, just CTRL+C, CTRL+V and WinMerging my way through most contribs :blush: ).

 

Maybe somebody can defeat this bug, or tell me what I'm doing wrong here.

 

Anyways, the idea behind this contrib is great and a lot of thanks to b00 for building it in the first place. But I think it could use some finetuning. If I find out something usefull, I will add it to this topic and hopefully help others.

 

Any help is very much appreciated!

 

Thanks in advance, and cheers

Link to comment
Share on other sites

  • 1 month later...
@ b00 (and englishchrissy, since you might have found this error as well):

 

I think I might have found a (minor) bug. Please other users (e.g. englishchrissy), could you check if this also happens to you when the contrib is added? Since I use a heavily modified OSCMax catalog, it might just be related to another contrib / setting of mine:

 

If your users surf to a products using the standard menu interface (e.g. category -> sub-category -> product-listing -> product), then the product is added nicely into you "recently visited". The link to the product works, and the "see more" gives a nice overview of all recently visited products. This is OK and how it should work.

If however your users surf to a product via the shopping_cart.php file (by clicking on a product that has been added to their cart), they are not send to the product page, but to the product page + selected attributes as how the product was added into the shopping cart (if the product has options / attributes). This is then recorded as a "recently viewed" product. This then results in an SQL error when you then try to open the recently_viewed.php page via the "See more" button (an SQL error appears related to the "productID{optionID}optionValue{optionID}optionValue" (which makes sense, in a way).

 

From what I can conclude, this is related to how the "recently_viewed.php" page queries the db for recently viewed products or how they are entered into the db from the "product_info" page. They do appear in the infobox, with a correct name and are "clickable" and the link brings you to the correct product page + options.

 

I must add that I've got the SEO urls installed and set to cPath, which might be related I think (remember, I'm not a real coder, just CTRL+C, CTRL+V and WinMerging my way through most contribs :blush: ).

 

To solve this I made a small modification on product_info.php recently_viewed code:

	   ///////////// begin recently_viewed
if (!tep_session_is_registered('recently_viewed'))
{
tep_session_register('recently_viewed');
$recently_viewed = $HTTP_GET_VARS['products_id'] . ';';
}
$acount=substr_count($HTTP_GET_VARS['products_id'],"{");
if ( $acount == 0 ) {
$dup_recent_viewed = 'n';
$recent_products = split(';',$recently_viewed);
foreach ($recent_products as $recent) {
if ($recent == $HTTP_GET_VARS['products_id']) $dup_recent_viewed = 'y';
}//foreach ($recent_products as $recent) {
if ($dup_recent_viewed == 'n') $recently_viewed = $HTTP_GET_VARS['products_id'] . ';' . $recently_viewed;
}
///////////// end recently_viewed

 

 

This line counts if there is any character: { which is on the link from de Shopping cart with attributes:

$acount=substr_count($HTTP_GET_VARS['products_id'],"{");

 

If the return value is equal 0 than continue with the recently viewed code. If its different from 0 means that its a link from shopping cart and does not include the product on the recently viewed list. (The correct link for the product already is included on the recently viewed list anyway.)

if ( $acount == 0 ) {

 

 

Solved my problem, hope it helps.

 

Regards

Edited by cururu
Link to comment
Share on other sites

I am very interested in this contrib, however I dont have the boxes on my site (just the categories and manufacturers) and would like the box in the product info page. Can anyone who has done this share their modification?

 

Thank you in advance.

Link to comment
Share on other sites

To solve this I made a small modification on product_info.php recently_viewed code:

	   ///////////// begin recently_viewed
if (!tep_session_is_registered('recently_viewed'))
{
tep_session_register('recently_viewed');
$recently_viewed = $HTTP_GET_VARS['products_id'] . ';';
}
$acount=substr_count($HTTP_GET_VARS['products_id'],"{");
if ( $acount == 0 ) {
$dup_recent_viewed = 'n';
$recent_products = split(';',$recently_viewed);
foreach ($recent_products as $recent) {
if ($recent == $HTTP_GET_VARS['products_id']) $dup_recent_viewed = 'y';
}//foreach ($recent_products as $recent) {
if ($dup_recent_viewed == 'n') $recently_viewed = $HTTP_GET_VARS['products_id'] . ';' . $recently_viewed;
}
///////////// end recently_viewed

 

 

This line counts if there is any character: { which is on the link from de Shopping cart with attributes:

$acount=substr_count($HTTP_GET_VARS['products_id'],"{");

 

If the return value is equal 0 than continue with the recently viewed code. If its different from 0 means that its a link from shopping cart and does not include the product on the recently viewed list. (The correct link for the product already is included on the recently viewed list anyway.)

if ( $acount == 0 ) {

 

 

Solved my problem, hope it helps.

 

Regards

 

I had to add this simple code after this line on product_info.php also:

if (!tep_session_is_registered('recently_viewed'))

 

The correct modification is the code below to be added at product_info.php:

 

 	   ///////////// begin recently_viewed
if (!tep_session_is_registered('recently_viewed'))
{
$acount=substr_count($HTTP_GET_VARS['products_id'],"{");
if ( $acount == 0 ) {
tep_session_register('recently_viewed');
$recently_viewed = $HTTP_GET_VARS['products_id'] . ';';
}
}
$acount=substr_count($HTTP_GET_VARS['products_id'],"{");
if ( $acount == 0 ) {
$dup_recent_viewed = 'n';
$recent_products = split(';',$recently_viewed);
foreach ($recent_products as $recent) {
if ($recent == $HTTP_GET_VARS['products_id']) $dup_recent_viewed = 'y';
}//foreach ($recent_products as $recent) {
if ($dup_recent_viewed == 'n') $recently_viewed = $HTTP_GET_VARS['products_id'] . ';' . $recently_viewed;
}
///////////// end recently_viewed

 

Regards

Link to comment
Share on other sites

  • 1 month later...
Hi,

 

I have installed this and all seems good however, when I click on "see more" the recently viewed page does not show any products.

 

I don't get any errors just a page of nothing.

 

Can anyone help me?

 

 

James

 

 

Same here. Any help? :blink:

Link to comment
Share on other sites

Hi,

 

I have installed this and all seems good however, when I click on "see more" the recently viewed page does not show any products.

 

I don't get any errors just a page of nothing.

 

Can anyone help me?

 

 

James

hey james -

could you post a link to your site so i could see what the problem is?

:>)

Edited by b00
Link to comment
Share on other sites

glad to see it is working

:>)

 

No, it is not working. The example I sent to you in the last message is a cart on the same server and domain but another cart (that is working). The one I mentioned to you first is still not working.

 

I just mentioned the one that is working because it is odd that one in the same server and domain is working and the other that is in a sub-folder but in the same domain is not showing the "see more" in recently viewed.

 

www.thedomain.com/catalog has the "see more" working, but www.thedomain.com/othername/catalog haas not working the "see more" of recently viewed (all other features of the cart are fine) I thought it was the cookie path but it seems that not. Any idea?

 

I am still with the problem, sorry :blush:

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

I like the look and idea of this contribution. Can anyone tell me if it is possible to add an image of the product along with its title to display in the recently viewed box. I would like it to look like the reviews and what's new box.

 

Thank you in advance,

Alexandra

Link to comment
Share on other sites

  • 4 weeks later...
Anyone know how to get this working with STS? STS v4.5.8 to be exact :)

 

Install as instructed but skip the part where you're asked to " Edit either catalog/includes/column_left.php or catalog/includes/column_right.php ".

 

Edit catalog/includes/modules/sts_inc/sts_user_code.php and add at the bottom before ?>

 

$sts->start_capture();

require(DIR_WS_BOXES . 'recently_viewed.php');

$sts->stop_capture('recent', 'box');

 

Edit your sts template and add into the right or left column

 

$recent

 

That's it. It works for me.

Link to comment
Share on other sites

  • 4 weeks later...

I've updated this contribution with several new features. Unfortunately I appear to have overdone it with the screenshots, so it's big enough to need a moderator's approval. If it doesn't show up in a few days I'll try again with smaller files. If you can't wait, email me and I'll send it to you. Features are:

 

An optional link in either side column to a page of recently viewed products.

 

An optional box in either side column with each product's image, name, and price, plus a button linked to a page of recently viewed products. The number of products shown and each of the elements can be controlled from tha Admin.

 

An optional box at the bottom of the page with each product's image, name, description, and price, plus a button linked to a page of recently viewed products. The products can be diplayed in a grid (like the New Products box) or in rows like the Category product list. The number of products shown, the length of the description, and each of the elements can be controlled from tha Admin.

 

A page with each product's image, name, description, price, and a Buy Now button. The number of products shown, the length of the description, and each of the elements can be controlled from tha Admin.

 

The database table added by the previous version has been removed.

 

Screenshots of both of the tables, the recently viewed products page, and the Admin page are included in the distribution.

 

This version is compatible with osCommerce 2.2RC2a, PHP 5.x, MySQL 5.x, and Register Globals on or off.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Dear sir,

if possible,can you write the complete steps about edit the follows files.

 

catalog/logoff.php

catalog/product_info.php

catalog/includes/column_right.php

catalog/includes/database_tables.php

catalog/includes/filenames.php

catalog/includes/functions/general.php

catalog/includes/languages/english.php

 

thank you veru much

Link to comment
Share on other sites

Sure. Backup your files first, then for each file:

1. Open the file from this Contribution and the corresponding file from your site in your file comparison utility.

2. Copy any differences (marked with "Recently Viewed") from the first file to the second.

3. Save the file.

 

See how easy that was?

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

  • 4 weeks later...

I am trying to install this contribution, but ran into a problem from the start. When I ran the query in the database, I got this error message:

 

SQL query:

 

#

# Add the configuration group

#### NOTE: Change the configuration ID in this line and the configuration data lines if it conflicts with data already in this table

#

INSERT INTO `configuration_group`

VALUES ( 111, 'Recently Viewed', 'Recently viewed boxes and page', 111, 1 ) ;

 

MySQL said: Documentation

#1062 - Duplicate entry '111' for key 1

 

So, what now? :blush:

 

Thanks,

 

Yol

I repeat myself when under stress, I repeat myself when under stress, I repeat myself...

 

--King Crimson (“Discipline”)

Link to comment
Share on other sites

#### NOTE: Change the configuration ID in this line and the configuration data lines if it conflicts with data already in this table

 

The instructions also cover this. The configuration ID used is 111. Change that to something that is not used in your store.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

#### NOTE: Change the configuration ID in this line and the configuration data lines if it conflicts with data already in this table

 

The instructions also cover this. The configuration ID used is 111. Change that to something that is not used in your store.

 

Regards

Jim

 

Thanks, Jim. I changed that and finished installation without any problems. I set 'show column box' to 'false' in the admin panel, so that only the bottom box would show, but the column one is still showing. I cleared my cache and it still shows.

 

How can I fix that?

 

Regards,

 

Yol

I repeat myself when under stress, I repeat myself when under stress, I repeat myself...

 

--King Crimson (“Discipline”)

Link to comment
Share on other sites

This looks a pretty handy mod ;-) One question - does it show the most recently viewed products by any and all customers on the site - or does it just show the recently viewed products of a particular customer?

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...