Replace 0 Reviews With Product Views or Sales

How to Replace “0 Reviews” With Product Views or Sales in WooCommerce

If you run a WooCommerce store, you already know that social proof can influence how shoppers interact with your products. Product reviews are one of the most common forms of social proof, but what happens when a product has no reviews yet?

Instead of displaying a plain “0 reviews” message, you can use that space to display useful product activity such as views today or number of purchases.

In this guide, we’ll show you how to create a WooCommerce Smart Rating Replacer that replaces the default zero-review display with product views or sales. The solution also tracks product views and prevents the same visitor from being counted repeatedly during the same day.

What Does the WooCommerce Smart Rating Replacer Do?

The custom WooCommerce functionality performs several tasks:

  • Detects products with zero reviews.
  • Tracks product-page views.
  • Filters out common search-engine bots and crawlers.
  • Uses a browser cookie to reduce duplicate views from the same visitor.
  • Stores today’s product views separately.
  • Maintains a lifetime product-view counter.
  • Retrieves WooCommerce product sales.
  • Replaces the zero-review output with a custom message.
  • Avoids displaying random or fabricated numbers.

For example, instead of showing:

0 reviews

your product page can display:

87 views today

or:

124 purchased

This gives products without reviews another way to communicate activity to shoppers.

Why Replace “0 Reviews” in WooCommerce?

A product showing “0 reviews” doesn’t provide much information to a potential customer.

For a newly launched product, this may simply mean that customers haven’t submitted reviews yet. However, the product could still be receiving traffic or generating sales.

Displaying product activity can make better use of the available space in the WooCommerce product rating area.

Potential messages include:

  • 25 views today
  • 87 views today
  • 124 purchased
  • 1,250 purchased

The important part is that these numbers should come from real store activity rather than arbitrary or randomly generated values.

How the WooCommerce Code Works

The solution uses the WooCommerce woocommerce_product_get_rating_html filter.

This filter allows us to modify the HTML generated for a product’s rating.

The key condition is:

if ( (int) $count !== 0 ) {
    return $rating_html;
}

This means products that already have reviews are left alone.

Only products with zero reviews are modified.

That is important because reviews should remain visible when genuine customer feedback exists.

Tracking Product Views

The plugin uses WordPress’s template_redirect action to detect product-page visits:

add_action( 'template_redirect', 'wsrr_track_product_views' );

The tracking function first checks whether the current page is a WooCommerce product page:

if ( ! is_product() ) {
    return;
}

This prevents the tracking code from running unnecessarily on pages such as:

  • Homepage
  • Shop archive
  • Blog posts
  • Cart
  • Checkout
  • Account pages

Only individual WooCommerce product pages are tracked.

Preventing Duplicate Views

One of the biggest problems with simple product-view counters is that every page refresh can increase the number.

For example, a customer could open a product page five times and accidentally generate five views.

The improved implementation uses a cookie associated with the product:

$cookie_name = WSRR_VIEW_COOKIE . $product_id;

If that cookie already exists, the visitor isn’t counted again during the current day.

This makes the counter more useful than simply incrementing the database every time a page loads.

Keep in mind that cookie-based tracking is not the same as analytics-grade unique-user measurement. Visitors can clear cookies, use different browsers or devices, or browse in privacy modes.

Tracking Today’s Views

The code stores the date separately from the daily view count.

For example:

_date: 2026-09-20
_views: 87

When the date changes, the system treats the previous counter as historical data and starts today’s counter from zero.

This approach has a useful advantage: you don’t need a cron job just to reset the daily counter.

When the next visitor arrives on a new day, the date comparison automatically detects the new day.

Why the Date Uses WordPress Time

The code uses:

current_time( 'Y-m-d' );

rather than relying directly on the server’s UTC date.

This is important for WooCommerce stores because WordPress has its own configured timezone.

As a result, “today” follows the WordPress site’s configured local timezone.

Filtering Out Bots

Search engines and crawlers can visit product pages automatically.

If every crawler visit were counted, your product-view numbers could become inflated.

The plugin therefore checks the user agent against common crawler identifiers:

$bots = array(
    'googlebot',
    'bingbot',
    'slurp',
    'duckduckbot',
    'baiduspider',
    'yandexbot',
    'sogou',
    'crawler',
    'spider',
    'bot',
);

This isn’t a perfect bot-detection system, but it provides a practical basic filter for common crawlers.

For high-volume stores, dedicated analytics or server-side bot filtering may be more appropriate.

Using WooCommerce Product Sales

WooCommerce provides a convenient method for retrieving a product’s total sales:

$sales = (int) $product->get_total_sales();

This gives you the product’s accumulated sales count.

For example, if a product has sold 124 units, the value will be:

124

The plugin can then display:

124 purchased

An Important Difference: Total Sales vs Today’s Sales

There is an important distinction here.

get_total_sales() represents total product sales, not sales from today.

Therefore, this would be accurate:

124 purchased

But this would not be accurate if you are using get_total_sales():

124 purchased today

If you specifically want to show today’s purchases, you need a separate mechanism that calculates orders and quantities for the current day.

This distinction is important when building trustworthy WooCommerce social-proof features.

Views and Sales Should Not Be Compared Blindly

The original concept compares sales and views and displays whichever number is larger.

For example:

if ( $sales > $daily_views ) {
    // Show sales
} else {
    // Show views
}

However, there is a major measurement issue.

You are comparing:

Lifetime sales

against:

Today’s views

Those two numbers represent different time periods.

Imagine a product has:

  • 2,000 lifetime sales
  • 75 views today

The code will display:

2,000 purchased

That may be perfectly legitimate, but it isn’t a direct comparison between equivalent metrics.

For a more transparent implementation, you could choose one of these approaches.

Option 1: Always Show Lifetime Sales

Display:

2,000 purchased

This is simple and based on WooCommerce’s total sales data.

Option 2: Always Show Today’s Views

Display:

75 views today

This emphasizes current product-page activity.

Option 3: Show Both

A more informative approach can be:

75 views today · 2,000 purchased

This avoids comparing two unrelated metrics and gives customers more context.

Why Random View Numbers Should Be Avoided

A common shortcut is to generate a random number when a product has no recorded views:

$views = rand(500, 1200);

Although this can make a product appear active, it doesn’t represent actual customer activity.

For a production WooCommerce store, it is better to display:

0 views today

or hide the message until real activity exists.

Using actual store data makes your implementation more reliable and easier to explain.

The Improved WooCommerce Rating Replacement Code

The complete implementation combines rating replacement, daily view tracking, duplicate-view protection, bot filtering, and basic styling.

The most important pieces are:

add_filter(
    'woocommerce_product_get_rating_html',
    'wsrr_product_rating_html',
    10,
    3
);

for modifying the rating output, and:

add_action(
    'template_redirect',
    'wsrr_track_product_views'
);

for tracking product visits.

The result is a lightweight WooCommerce customization that doesn’t require a separate product-view plugin.

Where Should You Add the Code?

You can implement this functionality as a small custom WordPress plugin.

Using a plugin is generally preferable to placing substantial custom functionality directly inside your theme’s functions.php, because the functionality can remain active when you change themes.

Create a PHP file such as:

woocommerce-smart-rating-replacer.php

Place the plugin header and code inside the file, upload it to your WordPress plugins directory, and activate it from the WordPress admin area.

Before deploying custom WooCommerce code on a live store, test it on a staging environment.

SEO Benefits of Product Activity Information

Displaying product views or sales isn’t a direct Google ranking factor.

However, improving the information presented to shoppers can contribute to a better overall ecommerce experience.

For example, a product page can communicate useful information without relying entirely on reviews:

  • Product popularity
  • Recent interest
  • Purchase volume
  • Customer activity
  • Product engagement

These elements can complement other ecommerce content such as:

  • Product descriptions
  • Specifications
  • FAQs
  • Product reviews
  • Images
  • Structured data
  • Internal links
  • Shipping information

The goal should be to provide useful information to shoppers rather than simply adding numbers for visual effect.

WooCommerce Product Views vs Product Reviews

Product views and product reviews serve different purposes.

Product views indicate that people are visiting a product page.

Product sales indicate that customers have purchased the product.

Product reviews provide customer-generated feedback and opinions.

None of these metrics replaces the others.

A product can have thousands of views but few purchases. Another product might have relatively little traffic but a strong purchase history.

That is why it’s useful to treat these metrics separately rather than assuming that a larger number automatically means a better product.

Best Practices for WooCommerce Social Proof

When implementing product activity counters, follow a few basic principles.

Use Real Data

Avoid arbitrary numbers whenever possible.

Your counters should be generated from actual WooCommerce or WordPress data.

Label the Time Period

If a number represents today’s activity, explicitly say:

views today

Don’t label a lifetime number as:

purchased today

Don’t Hide Genuine Reviews

If customers have submitted reviews, let the actual review information remain visible.

The customization should primarily address products with zero reviews.

Avoid Excessive Counters

Displaying too many numbers can make a product page feel cluttered.

Choose the metrics that actually help customers understand the product.

Test With Caching

WooCommerce stores frequently use page caching, CDN caching, or optimization plugins.

Because product pages can be cached, test your view-counting implementation carefully on your hosting environment.

Test Logged-In and Logged-Out Users

Make sure the counter behaves as expected for:

  • Guest visitors
  • Registered customers
  • Administrators
  • Search crawlers
  • Repeat visitors

Frequently Asked Questions

How do I replace “0 reviews” in WooCommerce?

You can use the woocommerce_product_get_rating_html filter to detect products with zero reviews and replace their rating HTML with a custom message such as product views or sales.

Can WooCommerce track product views?

WooCommerce itself isn’t primarily a product-view analytics system, but WordPress product-page hooks and custom post meta can be used to create a basic product-view counter.

Does WooCommerce get_total_sales() show today’s sales?

No. get_total_sales() represents the product’s accumulated sales count. It should not be labeled as today’s sales unless you separately calculate sales for the current date.

How can I count unique product views?

A simple implementation can use cookies to prevent the same browser from generating multiple views for the same product during a specified period. For more sophisticated analytics, use a dedicated analytics system.

Should I show product views or sales?

That depends on what information you want customers to see. Views communicate recent interest, while sales communicate purchase volume. If you use both, clearly label what each number represents.

Does showing product views improve SEO?

Product-view counters aren’t themselves a guaranteed Google ranking factor. Their primary purpose is to provide additional product-page information and potentially improve the shopping experience.

Final Thoughts

Replacing “0 reviews” with product views or sales in WooCommerce is a relatively simple customization that can make otherwise empty rating areas more useful.

The improved approach goes beyond simply changing the text. It tracks daily views, limits duplicate counting, filters common bots, preserves genuine WooCommerce reviews, and avoids generating random activity numbers.

The most important consideration is accuracy.

If you display views today, make sure the number represents today’s views. If you display purchased, make sure the number represents actual product sales. Clear labels and accurate data are more valuable than artificially large numbers.

For WooCommerce stores looking to add lightweight product activity indicators without installing a large analytics plugin, this custom rating replacement approach provides a flexible starting point.

Comments

Leave a Reply

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