Support » Plugin: YITH WooCommerce Advanced Reviews » The product rating stars disappeared aftrer reviews plugin

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter heino5

    (@heino5)

    I checked and realized that only the stars with no ratings actually disappear.

    But there is one more question. Before using the plugin, I need to convert the old reviews. What if at some point I don’t want to use the YITH plugin anymore. Will the reviews disappear?

    Regards,

    Plugin Author YITHEMES

    (@yithemes)

    Hello there,

    hope you are doing well 🙂

    By default, the plugin only shows the stars if the product has reviews. If you want to display also the stars for products without reviews, you have to add the following code to the functions.php file of your active theme:

    remove_filter( 'woocommerce_product_get_rating_html', array( YITH_WooCommerce_Advanced_Reviews::get_instance(), 'get_product_rating_html' ), 99 );
    
    if ( ! function_exists( 'get_product_rating_html' ) ) {
    	function get_product_rating_html( $rating_html, $rating ) {
    		global $product;
    		$rating_html = '';
    
    		if ( ! $product ) {
    			return $rating_html;
    		}
    
    		$rating = YITH_WooCommerce_Advanced_Reviews::get_instance()->get_average_rating( yit_get_prop( $product, 'id' ) );
    
    		if ( $rating >= 0 ) {
    			$rating_html  = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'yith-woocommerce-advanced-reviews' ), $rating ) . '">';
    			$rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'yith-woocommerce-advanced-reviews' ) . '</span>';
    			$rating_html .= '</div>';
    		}
    
    		return $rating_html;
    	}
    
    	add_filter( 'woocommerce_product_get_rating_html', 'get_product_rating_html', 10, 2 );
    }

    Regarding your second question, the reviews are also created as WordPress comments, so if you decide to not use the plugin, you will find all the reviews under the comments section.

    Try it and let us know any news, please.

    Have a nice day!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.