Load Recently Viewed Products with JavaScript and AJAX

  • Posts: 56
  • Thank you received: 1
  • Hikashop Business
7 years 11 months ago #270212

I am looking at how I can load recently viewed products using JavaScript and AJAX. This is so product pages can be served from a Varnish cache, and then have the recently viewed products, which is the only dynamic content on the page in my case (catalogue only mode), pulled in with AJAX on the client-side.

Is there anything existing that can do this, or go some way towards doing this? Just checking before I look at having something developed.

Thanks.


Professional website services including website management, Linux server admin and web hosting.
www.sharphosting.uk/

Please Log in or Create an account to join the conversation.

  • Posts: 83831
  • Thank you received: 13572
  • MODERATOR
7 years 11 months ago #270231

Hi,

The simplest way to get the recently viewed products from HikaShop is to enable the recently viewed products module (it's a module instance of HikaShop content module which is preinstalled with HikaShop to display that).
The issue with that in your case is that modules are supposed to be displayed on a template position and thus you have all the other modules and template around it.
Fortunately, Joomla has the tmpl=component parameter trick to be able to load a page with only the main content on it, without the modules and the template around.
Then, you just have to have that module displayed as main content. For example, with the load position content tag in a Joomla article, or with such extension: extensions.joomla.org/extension/m2c-module-to-component/
That way, you can have a URL you can call to get the HTML of the recently viewed products module, and you can use that URL in an AJAX request in your javascript.
That's the simplest and doesn't need any coding.

The following user(s) said Thank You: NigelPeck

Please Log in or Create an account to join the conversation.

  • Posts: 56
  • Thank you received: 1
  • Hikashop Business
7 years 11 months ago #270353

This is great info Nicolas, thanks. Should do what I need perfectly, will work on getting it set up.


Professional website services including website management, Linux server admin and web hosting.
www.sharphosting.uk/

Please Log in or Create an account to join the conversation.

Time to create page: 0.042 seconds
Powered by Kunena Forum