If your websites features products, a great way to improve the user experience is to provide visitors with a quick way to go back to products that they have recently viewed. As your visitors navigate your e-commerce website, they will probably see many of the products that are featured in the website. If you track the product page, you should be able to display a list of the recently viewed products. The {{woocommerce_recently_viewed_products}} binder allows you to track products and display a list of recently viewed products that will help visitors jump back to a product int the list.
/**
* This binder displays recently viewed products using WooCommerce default cookie.
*
* @param {array} $params
* $params['size'] Maximum number of products to be displayed (default: 5)
* $params['count'] --Alias for $params['size']
* $params['action'] Intended action. Valid values are "track" which will track the product pages or
* "show" which will render a list of recently viewed products.
* $params['show_last_first'] Whether or not to show the most recently viewed item at the beginning of the array returned.
* $params['error_message'] HTML string with a message to be display if no items have been viewed yet.
* $params['assign_to'] Variable within the template engine to which the content has to be assigned.
*/
Track
{{woocommerce_recently_viewed_products action="track"}}
Display
<section class="container-fluid text-center hot-text hidden-print">
{{woocommerce_recently_viewed_products size="5" assign_to="recently_viewed"}}
{{if count($recently_viewed) > 0}}
<div class="text-center">
<p>Recently viewed products</p>
</div>
<div class="text-center">
{{foreach $recently_viewed as $recent}}
<a title="{{$recent.post_title}}" class="recent" href="{{$recent.post_permalink}}">
<img class="img-responsive" src="{{$recent.post_thumbnail}}" />
</a>
{{/foreach}}
</div>
{{/if}}
</section>
