Skip Navigation

[Resolved] Conditional syntax

This support ticket is created 3 years, 8 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
- 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 7 replies, has 2 voices.

Last updated by Puntorosso 3 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2034791

Hi, surely a dumb question, but I cannot get this conditional to work.

[wpv-conditional if="( '[types field="trial-result" index="1" item="[wpv-search-term param='id']"][/types]' eq 'Negative' )"]

The test is negative.

[/wpv-conditional]

What am I doing wrong?

#2034993

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

It looks like there is issue due to quotes. Can you lease try to use the following code and check if that helps you to resolve your issue:

[wpv-conditional if="( '[types field='trial-result' index='1' item='[wpv-search-term param='id']'][/types]' eq 'Negative' )"]
 
The test is negative.
 
[/wpv-conditional]

Please make sure that the value you compare "Negative" is the correct value.

#2035125

Still not working.
If I use

[types field='trial-result' index='1' item='[wpv-search-term param='id']'][/types]

I get "Negative", so the shortcode is right.
But somehow the conditional doesn't resolve.

Tested with standard theme and only Toolset + WooCommerce activated (because the 'trial-result' is a custom field added to WC orders)

Here you can see a screenshot of the post and the results

hidden link

#2035147

Minesh
Supporter

Languages: English (English )

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

I will require to check on your install.

Can you please share problem URL where you added the conditional statement as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2035249

Minesh
Supporter

Languages: English (English )

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

I've added the following custom shortcode to "Custom Code" section offered by Toolset:
=> hidden link

function func_get_types_field_value($atts) {
    $field = $atts["field"];
   $index = $atts["index"];
    $id = $_GET['id'];
    return types_render_field($field,array('item'=>$id,'index'=>$index));
      
 }
add_shortcode("get-field-value", "func_get_types_field_value");

And we can call the above shortcode to get the value as: [get-field-value field='trial-result' index='1']

Then - I've used the above shortcode with conditional statement as given under:

[wpv-conditional if="( '[get-field-value field='trial-result' index='1']' eq 'Negative' )"]
The test is negative.
[/wpv-conditional]

And also I've registered the shortcode name at Toolset => Settings => Front-end Content => Third-party shortcode arguments

Can you please confirm it works at your end as well.

#2035283

Thanks for the workaround, I use something similar on the live site.

But any idea, why the "native" version doesn't work ?

#2035333

Minesh
Supporter

Languages: English (English )

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

Native way - there is nesting of shortcocdes and that should be the issue. To remove the nested shortcode issue with the conditional statement as a workaround we will have to use the custom shortcode I shared in previous reply.

#2035403

Ok, noted. Thanks.
Just interesting that this is also a nested shortcodes statement, but it works.

[types field='trial-result' index='1' item='[wpv-search-term param="id"]'][/types]

Seems to be a problem with Toolset conditionals.