Skip Navigation

[Resolved] how to use WooCommerce Product Reviews count in a conditional

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 5 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1198252

Tell us what you are trying to do? I'm creating a custom content template for a WooCommerce site. I want to use the Product Reviews count in a conditional to control whether or not the count and review(s) are displayed on the single product page.

What is the link to your site? hidden link

#1198370

Hello,

You can use Views shortcode [wpv-post-comments-number] to get the product review count, for example:
[wpv-post-comments-number none='0' one='1' more='%']

And use it insider wpv-conditional shortcode like this:

[wpv-conditional if="( '[wpv-post-comments-number none='0' one='1' more='%']' > 0 )" ]
This product has comment.
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-comments-number none='0' one='1' more='%']' > 0 )" evaluate="false"]
This product has not comment.
[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-comments-number
Displays the number of comments for the current post