I have a simple View that displays ticket prices for our events. There may be many pricing tiers, so ticket data is in a repeating field group. I've set up a View to loop through all the tickets for a given event, and everything works as expected.
Example:
Members — $0
Associate Members — $25
Guests — $65
As in the above example, some events are free for our members. Instead of "$0" I would like to say "FREE", but there doesn't seem to be any conditional logic available to do this in the loop template editor. It seems to be a strange limitation. Is this by design, and is there a workaround you can suggest?
Hello,
You can use [wpv-conditional] shortcode to check the custom field value, and display what you want, see below test site:
Login URL: hidden link
1) Setup the [wpv-conditional] shortcode as below:
hidden link
[wpv-conditional if=" ('[types field="ticket-price"][/types]' EQ '0') "]FREE[/wpv-conditional]
[wpv-conditional if=" ('[types field="ticket-price"][/types]' NQ '0') "][types field="ticket-price"][/types][/wpv-conditional]
2) Test it in frontend:
hidden link
It works fine.
More helps:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional
Thank you, that worked! However I wanted to mention that the price field isn't available in the "Insert conditional shortcode" dialog so I thought it wasn't recognized. I didn't realize that I could enter it manually.
Yes, you are right, since the ticket price field is in repeatable field groups, you need to setup the condition manually, for example:
[wpv-conditional if=" ('[types field="ticket-price"][/types]' EQ '0') "]FREE[/wpv-conditional]
[wpv-conditional if=" ('[types field="ticket-price"][/types]' NE '0') "][types field="ticket-price"][/types][/wpv-conditional]
Good to know. I'm a designer more than a coder, so the Toolset UI is very helpful for me to accomplish many things on my own, without the expense of an expert . I'm an early Toolset adopter, and glad that I purchased a Lifetime membership years ago, because your support is superb. My issue is resolved now. Thank you!