O
O
Oleg Marchenko2019-01-23 22:36:48
WooCommerce
Oleg Marchenko, 2019-01-23 22:36:48

How can I make the product rating in the store catalog (wooCommerce) according to the condition I set?

How can I make the product rating in the store catalog (wooCommerce) according to the condition I set?
The condition is if there are products on the page without a rating (stars), then do not display the rating (stars) on those products on which they are!? this is not an easy question! Maybe someone already did it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2019-01-24
@wppanda5 WooCommerce

function wpp_disable_empty_rating_in_archive( $html, $rating, $count ) {
  if ( ( is_shop() || is_product_category() || is_product_tag() ) && empty( $rating ) ) {
    return '';
  } else {
    return $html;
  }
}

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question