X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Recently Viewed Mod (https://forum.x-cart.com/showthread.php?t=36753)

royng 07-07-2009 05:02 PM

Re: Recently Viewed Mod
 
So, the "View all" feature, I guess no one know or this can't be done.

royng 07-09-2009 04:05 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by rick2003
I try to have the recently viewed product in my product.tpl,

http://www.lywoo.com/product.php?productid=61&cat=4&page=

however, it didn't work at all, I follow every steps. Could anyone help me do it.



It's working on your site now, how did you get the thumbnails how on the recently viewed? Thanks!

royng 07-10-2009 09:34 AM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by MoonDog
Here is a mod that will display up to four recently view products with icons and price that the customer has looked at. It doesn't use the db or php. It's strictly javascript and cookies. The default cookie is set to expire in 30 days, so that whenever the customer returns to your site within the 30 days, it will still show the four last viewed items that the customer has looked at. The time of expiry can be set for any amount of time, days or years.
I can't take full credit for this mod, since a lot of this code was grabbed from the internet. Unfortunately, I don't remember where I got these different codes, but thanks to those who created them. All I did was piece these codes together so that this will work in x-cart. I've tried this code for v4.1.8 and v4.1.9 and it seems to work O.K.

There's still a lot of room for improvement, so please feel free to add and contribute to this mod.

In customer/home.tpl add the following code between the <head> and </head> tags:
Code:


{literal}
<script type="text/javascript">
 function setCookie(name, value) {
 var today = new Date()
 var expires = new Date()
 expires.setTime(today.getTime() + 1000*60*60*24*30)
 document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +";path=/"
}
 function getCookie(Name) {
 var search = Name + "="
 if(document.cookie.length > 0) {
 offset = document.cookie.indexOf(search)
 if(offset != -1) {
 offset += search.length
 end = document.cookie.indexOf(";", offset)
 if(end == -1) end = document.cookie.length
 return unescape(document.cookie.substring(offset, end))}
 else return ""
 }
}
</script>
{/literal}

Now add these two lines of code in home.tpl wherever you want the Recently Viewed box to display(NOTE: this mod will not display recently viewed items when the menu box is on left side but only on the right side of your webpage or at the bottom(see Qdox post #36)).
If you want to use this mod on the left side just continue with the instructions and then go to post #42 to add the other code needed to make this work on the left column.
Code:


<br />
{include file="customer/main/recently_viewed.tpl"}

For instance: if you want to display the Recently Viewed box after the the news box, then find the {include file="news.tpl"} code and place the above code below it. Just make sure that this menu box is displayed on the right side of your webpage.

Add the following code to the end of your customer/main/product.tpl file:
Code:


<script type="text/javascript">
prodImage='<img src="{$product.tmbn_url}"/>';
prodName='<{$product.product}>';
var p0=('<br/><a href="'+document.URL+'">'+prodImage+'<br/>{$product.product}</a><br/>${$product.taxed_price}<br/>');
</script>

Create a customer/main/recently_viewed.tpl file by using the following code:
Code:


{capture name=menu}
<div class="recently">
{literal}
 <script type="text/javascript">
  if (p0){
  }
  else {var p0=null;
  }
  var p1=getCookie("p1");
  var p2=getCookie("p2");
  var p3=getCookie("p3");
  var p4=getCookie("p4");
  if (p1){
  }
  else {document.write("You have no recently viewed items.")
  }
  if (p1 !=null) {document.write(p1)}
  if (p2) {document.write(p2)}
  if (p3) {document.write(p3)}
  if (p4) {document.write(p4)}
  if(p0 !=null && p0 != p1 && p0 != p2 && p0 != p3 && p0 !=p4){
  setCookie("p1",p0)
  setCookie("p2",p1)
  setCookie("p3",p2)
  setCookie("p4",p3)
  }
 </script>
{/literal}
</div>
{/capture}
{include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title="Recently Viewed" menu_content=$smarty.capture.menu}

And finally, add the following code to the end of your skin1.css file:
Code:


.recently {text-align:center;}
.recently img {text-decoration:none;width:80px;height:auto;}
.recently a{text-decoration:none;color:black;}

And that should be it.

Update: Added attachment of before a product has been viewed and after viewing 2 products.
Also updated added code from post#7
Updated to inform that menu box will not work when displayed on the left side of the webpage. You will need to add the code that is posted on post #42 to display this mod on the left column.

Note: to set the day for when you want the cookie to expire, find this line of code:
Code:

expires.setTime(today.getTime() + 1000*60*60*24*30)
The number thirty at the end of that line is the number of days until the cookie expires. You can set it to any number of days you want. 7 is one week and 365 is one year.

- MoonDog -



Thanks for the code, but the thumbnails is not showing!

royng 07-14-2009 10:44 AM

Re: Recently Viewed Mod
 
This Code Has Problem!

On Some Computer, It's Show The The Recently Viewed With Just The Text And Link.

Other Computer Show A Empty Picture Box.

And I Don't See A Way It Can Be Fix!

royng 07-14-2009 01:01 PM

Re: Recently Viewed Mod
 
anything to do with

prodImage='<img src="{$product.tmbn_url}"/>';

in customer/main/product.tpl

Anyone?

shipmerchant 07-14-2009 07:12 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by MoonDog
pegpub and others,


For pegpub and those who have a two column layout or want to place the Recently Viewed mod on the left side, just do the following:

First of all, install the mod as outlined in Post #1 and placing the include recently_viewed.tpl anywhere in the left column in your home.tpl file.

Then create a file by copying the code below and name it recently_viewed_2.tpl and place it in the skin1/customer/main/ folder.
Code:


{literal}
 <script type="text/javascript">
  if (p0){
  }
  else {var p0=null;
  }
  var p1=getCookie("p1");
  var p2=getCookie("p2");
  var p3=getCookie("p3");
  var p4=getCookie("p4");
  if(p0 !=null && p0 != p1 && p0 != p2 && p0 != p3 && p0 !=p4){
  setCookie("p1",p0)
  setCookie("p2",p1)
  setCookie("p3",p2)
  setCookie("p4",p3)
  }
 </script>
{/literal}

And the last step is open the skin1/customer/home.tpl and find:
Code:


{include file="customer/home_main.tpl"}

And after that line place the following code:
Code:


{include file="customer/main/recently_viewed_2.tpl"}

Hopefully that should take care of the left column view problem.

NOTE: This modification is not needed if you place the Recently Viewed mod on the right column or in the middle column.

- MoonDog -



Great Mod MoonDog, just added and it works great. Thanks!

royng 07-15-2009 11:39 AM

Re: Recently Viewed Mod
 
shipmerchant,
Do you know how to fix the thumbnails problem?
it's showing the empty picture box

shipmerchant 07-15-2009 01:21 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by royng
shipmerchant,
Do you know how to fix the thumbnails problem?
it's showing the empty picture box



do you have 2 colums? added everything from Moon Dogs first post, then added the did recently_viewed_2.tpl from the post I qouted and all worked fine in all the browsers.
Did you try this already? The code works, you may want to double check everthing...

royng 07-15-2009 04:06 PM

Re: Recently Viewed Mod
 
Shipmercant, Thanks for your quick reply!

I only have 1 colum and I did add all Moondog's code.

I also add the Tabbed content Menu
http://forum.x-cart.com/showthread.php?t=11094
and it's not capturing any "Recently Viewed" at all, no matter how many products I view.

I hope you understand how stressful for a newbie working on a live store with limited ability and Thanks for you help.

royng 07-15-2009 04:21 PM

Re: Recently Viewed Mod
 
Quote:

Originally Posted by peterstagg
Hey Moondog
This is a really nice mod.
Thanks heaps!
It fits nicely with what I want and works smoothly.

I have a tabbed product menu and modified the menu and dialog templates and it does not seem to cause any problems. Are people still having those issues?

I also seemed to get it to work left side without any modifications that you suggested in #42, have you modified the code recently?

Cheers
peter


Hey! Peter, I have that problem with "Tabbed product menu" and the "recently viewed"

I still working on the "TPM", but the RV It's not showing the thumbnails and it's not capturing any recently viewed.

Do you have solution for it? Thanks


All times are GMT -8. The time now is 09:50 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.