Dynamic content display conditions - Woocommerce ratings

I’m working on custom layouts for WC single product pages, and have come to the customer reviews section.
I have set a condition on the section to only display if the product has reviews.
But, I would also like to add a secondary “AND” condition that checks if product reviews are enabled globally in the Woocommerce settings.
So, display if:

  1. Product has reviews AND 2. Product reviews are currently enabled

Maybe I’m missing something but I can’t see this option.
I can see there is a function called wc_review_ratings_enabled() that I could use, but before I go down that route I thought I’d ask the question here.
Thanks!

Hi @spedney,

Thanks for reaching out.
You can use the wc_review_ratings_enabled function in the custom layout, which checks if reviews ratings are enabled and return true or false.

Thanks

Ok. Thanks. But what about using this with a display condition in the layout builder - how is that?
Screenshot 2021-09-17 at 15.12.18

Hi @spedney,

The checking for the Enable product reviews is already integrated in the Layout Builder and you don’t need to add any specific condition for that.

Thanks

First, thanks for your help. You guys are really fast at responding these days!
Maybe I’m just tired after a long week but I can’t see how to do this…

I am in the layout builder. With a WC single layout.
I have a section at the bottom of my layout which contains reviews.
I want to only display this whole section if product reviews are enabled globally in Woocommerce settings.

Hello @spedney,

To achieve it you need to go to Layout builder —> Select the section —>Customize—>Condition.
Set the condition like please have a look at the given screenshot below

Please note it would work on the basis of the " Enable product reviews"

Hope it helps
Thanks

Thank you so much! Really appreciate your help!!

You are most welcome @spedney

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.