- This topic has 5 replies, 2 voices, and was last updated 6 years, 5 months ago by
David.
-
AuthorPosts
-
November 18, 2019 at 2:38 am #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
November 18, 2019 at 5:26 am #1066327David
StaffCustomer SupportHi 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(); ?>November 18, 2019 at 6:38 am #1066397Deniz 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.
November 18, 2019 at 6:55 am #1066524David
StaffCustomer SupportUnfortunately 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:
November 18, 2019 at 7:05 am #1066537Deniz Akay
Ok thanks anyway
November 18, 2019 at 7:45 am #1066565David
StaffCustomer SupportYou’re welcome – sorry i couldn’t provide a working solution for the Blocks.
-
AuthorPosts
- You must be logged in to reply to this topic.