I needed to code up a feature for a client which tracks a visitor “product_info.php” page views to basically show them what they recently viewed. I have to say that although I never thought about it, this is quite handy to have, as I have often been on the point of buying, looked at something else, then forgotten what product I was about to buy.
So, as the client is on 2.3.1 and we all know that there are barely any well written contributions for it, I decided to hack up an older contribution from kymation (Jim Keebaugh) who I know writes code in a very decent way…his contribution is here (5 Nov 2008 download).
The parts I used were the changes in product_info.php and logoff.php, this gives enough information to build an array of product IDs that have been visited. The array of product IDs is stored as part of the browsing session.
I then created a new infoBox to take that array and build up a gallery of recently viewed products. It looks like this;
I particularly made the images quite small in order to fit 4 in a row. The images are also linked to their respective product pages.
If there is nothing in the array (or, in plain english, the person viewing your site has not looked at any products) then this box does not show at all, no point in showing a box that has no contents!
I’m still fine-tuning the system, but overall, it seems to be solid.
Give me your views on it, please. Can it be changed to make it better, more interesting? I did think about changing the code showing the images to make it more like a fade in and out type effect, but then thought “whats the point” – after all this is a navigation history so everything needs to be seen at the same time.