Skip Navigation

[Resolved] Conditional Group Not Working

This support ticket is created 6 years, 6 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 15 replies, has 2 voices.

Last updated by aaronM-9 6 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#711609

I cannot seem to get a group of conditional fields to work properly. In the code pasted below, I would like the fields ad-response-satisfaction and ad-response-feedback to only show if field ad-response has been set to "Shipped or Delivered". However, it does not seem to work. When selecting "Shipped or Delivered" from the list nothing happens.

- Aaron

[credform class='cred-form cred-keep-original']

	[cred_field field='form_messages' value='' class='alert alert-warning']

	<div class="form-group">
		[cred_field field='ad-response-seller' post='ad-response' value='' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap']
	</div>

	<div class="form-group">
		[cred_field field='ad-response-text' post='ad-response' value='' urlparam='' class='form-control' output='bootstrap']
      	[cred_field field='ad-response-private' post='ad-response' value='' urlparam='' output='bootstrap']
	</div>

[cred_show_group if="($(ad-response-seller) eq  'Shipped or Delivered' )"  mode='fade-slide']
	<div class="form-group">
		<label>Satisfaction</label>
		[cred_field field='ad-response-satisfaction' post='ad-response' value='' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap']
	</div>

	<div class="form-group">
		<label>Best/Worst Part</label>
		[cred_field field='ad-response-feedback' post='ad-response' value='' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap']
	</div>
[/cred_show_group]

	[cred_field field='ad-response-buyer' post='ad-response' value='n/a' urlparam='' class='hidden' output='bootstrap']
	[cred_field field='_wpcf_belongs_ad_id' value='[wpv-attribute name="adid"]' class='hidden' output='bootstrap']
	[cred_field field='post_parent' value='[wpv-attribute name="postparentid"]' class='hidden' output='bootstrap']

	[cred_field field='form_submit' value='Submit' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']

[/credform]
#713341

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Aaron

The value in the condition needs to be the stored value not the display value.

Where you have defined the options of the ad-response-seller custom field at Toolset > Post Fields, is "Shipped or Delivered" the display text or the custom field content? You need to use the value from "custom field content" in your comparison.

#729826
temp3.jpg

That text is both the value as well as the display value. See screenshot.

- Aaron

#731989

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hmmm. Everything looks okay from here.

Can you check the browser console to see if there are any JS errors on the page?

#738522
temp.jpg

Attached please find the error messages being received.

- Aaron

#743419

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Aaron

The JS errors you see there are the reason the conditional display isn't working (because the JS cannot run), but it is not clear where the errors are coming from.

Can you first deactivate all non-Toolset plugins and then re-visit the page?

I suspect you will no longer see the same errors.

In fact if you try the opposite, disable only the Toolset plugins and re-visit the page you will still see the errors.

It would be a process of elimination to work out which plugin is causing the issue. (Try Jetpack, first.)

Let me know what you find.

#748068

Hi Nigel,

You were right. I disabled Autoptimize and the MOST of the conditional group started working. Turns out Autoptimize was also having a similar affect on another plugin as well. Looks like I won't be able to use Autoptimize. However, that being said, one lingering field still refuses to show, and I can't figure out why. I've disabled other plugins that I thought could be responsible such as JetPack and WP Hide & Security, but the problem keeps persisting. The "Best/Worst Part" label now appears but the select field it's associated with does not. The "Satisfaction" label and field both work just fine now. They are all contained within the same condition group.

- Aaron

#748069

PS - When inspecting the HTML, the select box is taking a "display: none" property, but I don't know what's setting it.

#749710

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Can I get access to your site so that I can check what's happening?

What page can I see this on the front end?

Can you provide admin credentials in the next, private, reply.

#767829

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-04-30 at 12.32.15.png

Hi Aaron

I logged in but was unable to see the ad post you linked to, and when I visit the list of ad pages in the back-end, none are visible (although the post count shows that there are some).

Something fairly low-level is wrong here, which may be coming from another plugin, but I don't want to make any changes such as de-activating non-Toolset plugins because I don't know if your site is live.

#768020

The form isn't displaying because this code inside view "View-Ads-Responses-01-Initial" doesn't seem to be working properly (or maybe I'm using it incorrectly):

			[wpv-conditional if="( $(wpcf-ad-type).id(ad) eq 'Seeking' ) AND ( '[wpv-post-author format="meta" meta="ID"]' eq '[wpv-user field="ID"]' )"]
				<p><a href="JavaScript:be_changevisibility('reply[wpv-post-id]')">Reply</a></p>
				<div id="reply[wpv-post-id]" style="display:none">[cred_form form="form-ad-response-seller"]</div>
			[/wpv-conditional]
...
			[wpv-conditional if="( $(wpcf-ad-type).id(ad) eq 'Seeking' ) AND ( '[wpv-post-author format="meta" meta="ID" id="$ad"]' eq '[wpv-user field="ID"]' )"]
				<p><a href="JavaScript:be_changevisibility('reply[wpv-post-id]')">Reply</a></p>
				<div id="reply[wpv-post-id]" style="display:none">[cred_form form="form-add-response-buyer"]</div>
			[/wpv-conditional]

For some reason, all of my conditional statements referencing parent post types have stopped working.

https://toolset.com/forums/topic/conditional-code-based-on-field-value-of-a-parent-post-type-not-working/

Perhaps we should hold until this other issue gets resolved. Sorry, this one popped up after I opened the other ticket.

To answer your other question - the site is not live. I'm racing the clock right now to get it ready by mid-June.

- Aaron

#769176

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Aaron

I did some testing on your site but I can't see why it's not working to do something as simple as display the list of Ads in the backend. I've taken a copy of your site to install locally where it will be easier for me to do some more testing.

I'll get back to you.

#769339

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Aaron

I don't have a problem viewing the Ad posts on my locally installed version of your site, so it appears to be something specific to your server.

It could be something like a memory issue, but there should be clues in the error logs.

The FTP credentials you provided didn't work, but I did notice when creating a duplicate that you have a very large debug.log file (7Mb).

I suggest you use FTP and delete it, then navigate the back-end of your site, specifically viewing the list of Ad posts, which comes up empty when I visit it, and check the debug log for any PHP warnings or messages.

Let me know what you see.

#770501
temp.jpg

Yeah my debug log is constantly getting hit with errors from WooCommerce. I've opened up a ticket with them to lock down what's happening. Hopefully I can get that figured out soon.

Accessing Ads on the back-end has never been an issue for me - interesting that it doesn't work for you.

#772813

Hi Nigel,

Okay - I've fixed the issue. The reply form may not have been displaying for you if you weren't logged in using the test@test.com address since logging in as anybody else won't show the reply form because that user is not an active participant in the conversation.

I cleaned up some of my conditional statements, so those are now working. I had to use shortcodes instead of the $xx variables when referencing parent post types.

[wpv-conditional if="( '[types field="ad-response-responder"][/types]' eq 'Seller' ) AND ( '[wpv-post-author format="meta" meta="ID"]' eq '[wpv-user field="ID"]' )"]
	<p><a href="JavaScript:be_changevisibility('reply[wpv-post-id]')">Reply</a></p>
	<div id="reply[wpv-post-id]" style="display:none">[cred_form form="form-ad-response-seller"]</div>
[/wpv-conditional]

That got me part-way there, and then I realized the text field wasn't displaying on the form because in the custom field setup I had used AND instead of OR in the conditional logic. Even though the form itself was using the correct logic, the underlying custom field was not, so this was causing the input box to remain hidden.

Sorry to have bothered you with this. Hope you didn't sink too much time in. I continue to be impressed at the level of service you guys provide and hope I'm not too much of a bother. Cheers.

- Aaron