[Support request] Reviews Block

Home Forums Support [Support request] Reviews Block

Home Forums Support Reviews Block

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1066202
    Deniz Akay

    Hello,

    I’m trying to implement woocommerce’s new “reviews block” to my products with a hook but it doesn’t work (I checked “execute php” box). It works if I add it to product description but this time it removes all paragragraphs next to it from product info.

    And as a next step I need to pull product id dynamically and set it in the code. Is there a way to do that? Creating a new hook for every single product is a lot of work and it can cause performance issues.

    Here is my sample code:

    <!-- wp:woocommerce/reviews-by-product {"editMode":false,"orderby":"highest-rating","reviewsOnPageLoad":4,"showLoadMore":false,"showOrderby":false,"showReviewImage":false,"productId":3894} -->
    <div class="wp-block-woocommerce-reviews-by-product wc-block-reviews-by-product has-name has-date has-rating has-content" data-image-type="reviewer" data-orderby="highest-rating" data-reviews-on-page-load="4" data-reviews-on-load-more="10" data-show-load-more="false" data-show-orderby="false" data-product-id="3894"></div>
    <!-- /wp:woocommerce/reviews-by-product -->

    More info about new blocks: https://woocommerce.wordpress.com/2019/08/29/woocommerce-blocks-2-4-release-notes/

    Thanks

    #1066327
    David
    Staff
    Customer Support

    Hi there,

    i don’t think this is possible currently with Blocks.
    Why not use the Reviews that are built into the single product template?

    It is possible to move them from outside of the tabs and hook them elsewhere.
    To do that you would unset the reviews tab with this PHP snippet:

    add_filter( 'woocommerce_product_tabs', '_remove_reviews_tab', 98 );
    function _remove_reviews_tab( $tabs ) {
      unset( $tabs[ 'reviews' ] );
      return $tabs;
    }

    The you can hook the comments form back into the Product pages:

    <?php comments_template(); ?>

    #1066397
    Deniz Akay

    Hello David,

    I want to customize reviews, like showing latest 3 or 4 reviews with highest rating, hiding comment form and avatar etc. Comment blocks allow me to do these.

    #1066524
    David
    Staff
    Customer Support

    Unfortunately it is not possible to the best of my knowledge as the block data is stored in the post meta along with the CSS which wouldn’t get pulled in via the Hook.

    Maybe this PHP provided here will provide what you need:

    https://stackoverflow.com/a/30273532

    #1066537
    Deniz Akay

    Ok thanks anyway

    #1066565
    David
    Staff
    Customer Support

    You’re welcome – sorry i couldn’t provide a working solution for the Blocks.

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