Skip Navigation

[Resolved] Conditional statement based on Checkboxes field not working as expected

This support ticket is created 4 years, 11 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Ronald 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1433213
Annotation 2019-12-31 141056.jpg
Annotation 2019-12-31 141158.jpg

I have a custom field for Services Offered, it has about 5-6 options, then an "Other" option.

In the View, I have a conditional statement (below) that checks if the Services Offered field has "Other" checked, and if so, displays a link to view more info.

The issue I am having is that if "Other" is the only option checked, the conditional code displays properly, but if they have multiple options selected and "Other" selected as well, the conditional code does not display.

Below is the Conditional Shortcode I am using and I have attached screenshots.

Shortcode: [wpv-conditional if="( $(wpcf-services-offered) eq 'Other' )"] (View all)[/wpv-conditional]

Thanks

#1433893

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset offers two ways using which you can display the conditional content based on the checkbox option selection for checkboxes field.

1)
Use the [wpv-conditional] shortcode:

[wpv-conditional if="( '[types field="services-offered" option="0"][/types]'  eq 'option_value' )"]
   option 0 is checked
[/wpv-conditional]
[wpv-conditional if="( '[types field="services-offered" option="1"][/types]' eq 'option_value' )"]
     option 1 is checked
[/wpv-conditional]

Where:
- Replace 'option_value' with your original option value

2)
Use the Types shortcode to check the current state of checkboxes option:

For example:

[types field="services-offered" option="0" state="checked"]
text to display when option 0 is checked 
[/types]
 
[types field="services-offered" option="0" state="unchecked"]
text to display when option 0 is not checked.
[/types]

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

#1443305

My issue is resolved now. Thank you!