geminilabs

Woodmart product rating counts

Aug 10th, 2025 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. /**
  2.  * This fixes the "Show reviews count" option in the WoodMart theme.
  3.  *
  4.  * @see https://woodmart.xtemos.com/
  5.  */
  6. function glsr_woodmart_product_rating_count($html) {
  7.     global $product;
  8.     if (!function_exists('woodmart_get_opt') || !function_exists('woodmart_show_reviews_count')) {
  9.         return $html;
  10.     }
  11.     if (!is_a($product, 'WC_Product')) {
  12.         return $html;
  13.     }
  14.     if (str_contains($html, 'wd-star-rating')) {
  15.         return $html;
  16.     }
  17.     if (woodmart_get_opt('show_reviews_count')) {
  18.         ob_start();
  19.         woodmart_show_reviews_count();
  20.         $html .= ob_get_clean();
  21.     }
  22.     return sprintf('<div class="wd-star-rating">%s</div>', $html);
  23. }
  24. add_filter('woocommerce_product_get_rating_html', 'glsr_woodmart_product_rating_count', 25);
Advertisement
Add Comment
Please, Sign In to add comment