Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1186455
    Loren N
    Participant

    Hi,

    I’d like to show an aggregated review star rating on product pages. I was following this thread for the same stack (integrity) and added code to functions.php as detailed but it didn’t work. In fact it gave me an error.

    https://community.theme.co/forums/topic/aggregate-rating-not-showing-in-google-structured-data-testing-tool/

    Can you help please?

    Thanks,
    Loren

    #1186573
    Rupok
    Member

    Hi Loren,

    Thanks for writing in! This is something not related to X rather custom development for WooCommerce as it’s not part of WooCommerce as well rather extending that. I think Rad explained that on other thread – https://community.theme.co/forums/topic/aggregate-rating-not-showing-in-google-structured-data-testing-tool/page/2/#post-1134600

    Thanks for understanding.

    #1186618
    Loren N
    Participant

    …but Christian provided a solution. I just couldn’t get the code (which seemed to be split across 2 replies) to work (maybe because I missed something like a comma or something) so I got an error.

    When I change to a basic Twentysixteen theme, the review stars are present which means that its a basic and included function in Woocommerce. It’s within the X template that overrides the woocommerce one where the stars don’t show, therefore, it’s an X issue, therefore I need help to fix the X template.

    #1186761
    Darshana
    Moderator

    Hi there,

    I have checked with the development team and this issue will be fixed in an upcoming release of X. In the meantime, try adding the following code into your child theme’s functions.php file.

    
    add_action('after_setup_theme','woocommerce_default');
    
    function woocommerce_default() {
      add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
    }
    
    function x_woocommerce_shop_product_thumbnails_fix() {
    
      GLOBAL $product;
    
      $id     = get_the_ID();
      $thumb  = 'entry';
      $rating = $product->get_rating_html();
    
      woocommerce_show_product_sale_flash();
      echo '<div class="entry-featured">';
        echo '<a href="' . get_the_permalink() . '">';
          echo get_the_post_thumbnail( $id, $thumb );
          if ( ! empty( $rating ) ) {
            echo '<div class="star-rating-container aggregate" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">' . $rating . '</div>';
          }
        echo '</a>';
      echo "</div>";
    
    }
    

    Hope that helps.

    #1186795
    Loren N
    Participant

    Awesome! Code worked perfectly and I look forward to it being included on a future X release.

    Thanks.

    #1186829
    Joao
    Moderator

    Glad to hear it Loren,

    Have a great day and thanks for using X.

    Joao

  • <script> jQuery(function($){ $("#no-reply-1186455 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>