Question

This sounds very confusing I know. Basically for an e-commerce store, I need to have recently viewed items show up vertically in the sides of my pages either left or right or both. The thing is I can not figure out how to code it. I figured the script would be in javascript and then called to through HTML on the pages I need it on. I'm not 100% sure where to get started and would gladly appreciate any assistance. I know this is a shot in the dark, but I have to try something. Figured the extremely smart people on here might be able to solve this mystery for me. If it is any help, the e-commerce site I am building this store with is Volusion. If you have any questions I would be glad to answer them. Thank You.

I should let you know, that I know the basics of HTML, not enough to write from scratch though so any help will have to be explained. I just need to figure this out for my client. Thank You.

Was it helpful?

Solution

You will want to store the recently viewed products in the session (or in a cookie).

Here's one potential resource for storing (and retrieving) that information: http://www.quirksmode.org/js/cookies.html

With that, you should be able to inject the appropriate HTML into your page.

OTHER TIPS

For that you need PHP. You can set the cookies and then you can view them as specified in the link

I know this has been answered, but I wanted to elaborate for anyone who is still having trouble with this, especially since it seems like no one (other than the OP) has taken into consideration he is using Volusion.

So, for the first answer, I want to point out that No, Don't need PHP to do this, and since this is a volusion issue, you definitely don't want to try to solve it in PHP, since their servers do not support PHP...

The other answer is definitely on the right track, except I'd like to point out that volusion already provides this functionality and already stores the info in a cookie so there isn't any reason to create your own.

I'd suggest doing so in JavaScript; However, before you go and try to custom code a solution, check out this link:

Volusion's "My Recent History Widget" - Displaying A Customers Recently Viewed Products

You could manipulate this functionality using JavaScript and do a client side change of where that is placed on the page, and/or change the actual html code they insert into your page for it.


Or if you want to do it with a more customized solution, Please read the following:


Volusions Software Cookies; Including Functionality Cookies

Functionality Cookies

These cookies are used for some of the more enhanced features available with Volusion. You can disable these features to prevent these cookies from being stored on customers’ browsers.

History50 – This cookie stores the ProductIDs of the last items viewed by a customer on your store. This cookie is used to control the My Recent History functionality, which can be set to appear at the bottom of all product pages as your customers browse your site..."

In order to access the cookie information using JavaScript you can use a code such as:

    function getCookie(name) {
      var name = cname + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1);
        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
      }
      return "";
    }

To Explain the above code for those of you that might be beginners

  1. Assign the cookie name as a parameter (cname)
  2. Create a variable (name) and include what you want to search for (cname + "=")
  3. Split document.cookie on semicolons into an array and call this ca (ca = document.cookie.split(';')).
  4. Loop through the array you just created (i = 0; i < ca.length ; i++)
  5. Read out each value (c=ca[i])
  6. If the cookie is found, it will return the value of it.
  7. If it's not, it will return "" (null)

You'll want to put that script in the section of your page... And later on when you want to actually use the data, you'll want to use something along the lines of this:

    var x = getCookie("cookiename")
if (x) {
[do whatever you want with x here]
}

Obviously this is not the exact code you will use to create your custom recently viewed products widget, but, it will give you the concepts you need in order to do so.

Some quick google searches on "use cookies in JavaScript" will return more information than you could ever use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top