Boost Sales and Engagement with WooCommerce’s Recently Viewed Products Plugin: A Step-by-Step Guide

As a store owner, it’s essential to provide your customers with a personalized shopping experience. One way to enhance this experience is by showing them the products they have recently viewed. This feature allows users to quickly navigate back to previously seen items and potentially increase conversions.

In this blog post, we will walk through the process of building a Recently Viewed Products plugin for WooCommerce. This plugin will display recently viewed products on your site, send an email reminder to customers after 5 days, and support dynamic customization options through a shortcode.

Step 1: Setting Up the Plugin

To begin, let’s create a custom plugin. We’ll structure the plugin file so that it’s easy to expand and customize later on.

Plugin Header

Start by creating a file called recently-viewed-products.php and include the following plugin header at the top:

Shortcode to Display Recently Viewed Products

We’ll create a WooCommerce shortcode [recently_viewed_products] that will display the recently viewed products on any page or post. This shortcode will accept various parameters like per_page, orderby, order, category, and columns for dynamic customization.

Track Recently Viewed Products

We will track the products that a customer has viewed and store the information in a cookie. This way, the data is accessible on every page load.

Send Email After 5 Days

Now, we will create a system that sends an email reminder to users 5 days after they viewed a product, provided they have viewed at least 5 products. This is done by checking timestamps associated with the viewed products.

Email Timing

To send the email after 5 days, we will check the timestamp of when the product was viewed and compare it with the current time. If 5 days have passed and the user has viewed at least 5 products, the email will be sent.

Step 2: Plugin Activation and Usage

  1. Upload the Plugin: Upload the plugin file (recently-viewed-products.php) to the /wp-content/plugins/ directory of your WordPress installation.
  2. Activate the Plugin: Go to the WordPress admin dashboard, navigate to Plugins, and click Activate for the Recently Viewed Products plugin.
  3. Add the Shortcode: Once the plugin is activated, use the shortcode [recently_viewed_products] to display the recently viewed products anywhere on your site (e.g., in pages, posts, or widgets). Example:
  1. Email Reminders: After 5 days of viewing products, an email will be sent to the logged-in user, displaying the products they recently viewed.

Conclusion

This plugin allows you to provide a more personalized shopping experience for your customers. By displaying recently viewed products and sending email reminders, you can increase engagement and potentially drive more sales.

You can further enhance this plugin by customizing the email content, adding more filters for product queries, or integrating it with other WooCommerce features like dynamic discounts.

If you have any questions or need additional features, feel free to reach out in the comments below!

Leave a Reply

Your email address will not be published. Required fields are marked *