Skip Navigation

[Resolved] Conditionl Output if WooCommerce Product is in Category

This support ticket is created 7 years, 5 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
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Tia 7 years, 5 months ago.

Assisted by: Tia.

Author
Posts
#458011

Hi I am trying to show a section of content on a content template if the current product is in a certain category.

So, if Product X is in Product Category 'Voiceovers' then show Y HTML.

So far I have tried both of these but I think I am going rather wrong, any help would be appreciated 🙂

[wpv-conditional if="( has_term('voiceovers', 'post_category', null) = true )"]
HTML HERE
[/wpv-conditional]
  
[wpv-if evaluate="has_term('voiceovers', 'category', null) = true"]    
HTML HERE
[/wpv-if]
#458092

Tia

Thank you for contacting Toolset Support. I am happy to help you with this. I am currently working on this ticket and will respond shortly with feedback.

#458355

Thanks, looking forward to your response 🙂

S

#458517

Tia

Just letting you know I am still testing a few things on my end and should be responding shortly with feedback.

#459240

Tia
has-term.jpg

There are a couple things to update:

1. Use product_cat instead of post_category

2. Go to Toolset > Settings > Front-end Content and make sure has_term is added to "Functions inside conditional evaluations" (see screenshot).

The code below should work:

[wpv-conditional if="( has_term('voiceovers', 'product_cat', null) eq '1' )" evaluate="true"]
HTML HERE
[/wpv-conditional]

Please let me know if this resolves the issue or if it needs more investigation.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.