Announcement:Materials and articles for ProductCart 5 can be found at our brand new support center.

Create an account to edit articles | See Formatting Syntax for Wiki syntax | We look forward to your contribution!

Recently Viewed Products Widget

What it does

Now you can add a simple line of code to your store design (anywhere on your store's graphical interface) that will list the last few products visited by a customer (you can easily set how many are shown). By default, the last 10 products viewed in the storefront are listed.

The feature uses a harmless cookie on the customer's computer, so recently viewed products are shown even if the customer leaves the store and comes back a few days later.

An intuitive “Clear List” link allows the customer to instantly clear the list.

Adding it to your store

To add the “Recently Viewed Products” widget to your ProductCart-powered store, simply add this line of code in the location where you want the products to be shown. Typically, it is added in left- or right-side column. Depending on how your store has been designed, the code will be added to either “pc/header.asp” or “pc/footer.asp”.

<!--#include file="smallRecentProducts.asp"-->

To confirm that the feature is working properly, visit any product details page. The list of previously visited product should now list that product.

The list of products recently viewed by a customer is saved to a harmless cookie on the customer's computer system. The cookie is called “pcfront_visitedPrds”. This means that the list of products will be saved even when the browser is closed. Customers can instantly clear the list by using the “Clear List” link.

File Download

The “Recently Viewed Products” widget is included in ProductCart v3.1 and above. It should be compatible with all ProductCart v3 stores. So if you don't have it, you can download it here (updated on 10.21.08). The file changed in version 4 (the file available here contains both versions).

The McAfee Secure service reported a vulnerability in the smallrecentproducts.asp file in October of 2008. Download the latest version, unzip it and upload it to the “pc” folder to resolve the vulnerability. If you purchased or updated ProductCart after October of 2008, you should already have the latest version of the file.

Number of products shown

To change the number of products to show in the list, follow the instructions below. By default, the last 10 products viewed by the customer are shown.

  • Locate the file “smallRecentProducts.asp” in the “pc” folder
  • Create a back-up copy before editing it
  • Open it in Notepad or your favorite HTML editor
  • Locate the following line and replace the number 10 with a new one
'// The maximum products to show
MaxProducts=10
  • Save the file and upload it back to your Web server

Changing the style

The ID of the DIV that displays recent products is “recentprds”. So you can easily style it by adding a new style definition to ProductCart's main storefront stylesheet (“pc/pcStorefront.css”). For example, you could add something like this to pcStorefront.css:

#recentprds {
	background-color: #F7F7F7;
	color: #666666;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 9px;
}

Adding the AJAX preview

You can add the AJAX product preview to Recently Viewed Products by replacing the existing link to the product details page with the following code:

<a href="viewPrd.asp?idproduct=<%=tmpVPrdArr(0,tmpIndex)%>" <%if scStoreUseToolTip="1" then%>onmouseover="javascript:document.getPrd.idproduct.value='<%=tmpVPrdArr(0,tmpIndex)%>'; sav_callxml='1'; return runXML1('prd_<%=tmpVPrdArr(0,tmpIndex)%>');" onmouseout="javascript:sav_callxml=''; hidetip();"<%end if%>><%=ClearHTMLTags2(tmpVPrdArr(1,tmpIndex),0)%></a>

Troubleshooting

If the “Clear List” feature is not working the reason is probably that you moved smallRecentProducts.asp to another folder (e.g. to the root of the web site), but did not change the references to the ASP page that performs the task of clearing the list. Specifically, you will have to edit the two lines of smallRecentProducts.asp that reference clearViewedPrdsList.asp.

For example, in the sample code below, the two lines of code were edited to account for the fact that the file was moved 2 directories up. Here the “productcart” folder had been renamed “store”, so the path to the file clearViewedPrdsList.asp becomes “store/pc/clearViewedPrdsList.asp”.

<iframe id="clearViewedPrdListCookie" src="store/pc/clearViewedPrdsList.asp" frameborder="0" width="0" height="0">
</iframe>
<script>
function ClearViewedPrdList()
{
document.getElementById('recentprds').style.display='none';
document.getElementById('clearViewedPrdListCookie').src="store/pc/clearViewedPrdsList.asp?action=clear";
}
</script>

QR Code
QR Code Recently Viewed Products Widget (generated for current page)