Show Product Percentage instead of Comment Count on WooCommerce

December 9, 2020

Hi WooLovers.

Today, We’re going to manipulate comment counts. Numbers are good but visualizing something is much more sense for the customer. The web is full of text and people only scan this text but when we see images or visual things we give pay attention. So you can visualize this code by CSS and get your customer’s attention.

Add the following code on your functions.php

/*
 *  Remove default rating code from woocommerce\templates\single-product\rating.php 
 *  Can do same thing by editing that template file
 *  Add the following code on your functions.php
*/ 
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);

add_action( 'woocommerce_after_shop_loop_item_title', 'amc_function_add_rating_percentage', 5  );
add_action( 'woocommerce_single_product_summary', 'amc_function_add_rating_percentage', 5  );
function  amc_function_add_rating_percentage() { 
    global $product;  
    $rating_count = $product->get_rating_count(); 
    $average      = $product->get_average_rating(); 
    $average_percent = $average * 100/5;
    if($rating_count >0){
        echo '<div class="woocommerce-product-rating">'.wc_get_rating_html( $average, $rating_count ).esc_html__( '('.$average_percent.'% customers satisfied )' , 'amc' ).'</div>'; 
    }
    
}

Another tip is showing discount percentage as a label on product images. This can increase your sellings. Click here to learn how to it.

Tags

What do you think?

What do you think?

3 Comments:
September 11, 2024

Модные советы по выбору крутых луков на каждый день.
Заметки экспертов, новости, все новые коллекции и мероприятия.
https://sochidaily.ru/read/2024-09-10-demna-gvasaliya-ikona-sovremennoy-mody-i-kreativnyy-revolyutsioner

September 28, 2024

Модные советы по подбору модных видов на любой день.
Статьи экспертов, новости, все дропы и мероприятия.
https://sneakero.ru/sneakers/1695-krossovki-new-balance-237-sovremennye-ottenki-retro

October 3, 2024

Стильные заметки по подбору модных луков на каждый день.
Заметки профессионалов, события, все показы и шоу.
https://lecoupon.ru/news/2029-10-02-7-prichin-lyubit-brend-herno/

Leave a Reply

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

More notes