Skip Navigation

[Resolved] Conditional logic with repeatable field groups

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 4 replies, has 2 voices.

Last updated by Dan Kitsmiller 1 year, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2617103
Screenshot 2023-06-19 at 4.06.34 PM.png

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?

#2617163

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

#2617441
Screenshot 2023-06-20 at 5.45.51 PM.png

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.

#2617471

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]
#2617473

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!