Skip Navigation

[Resolved] Displaying woocommerce categories conditionally based on generic field input

This support ticket is created 3 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.

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: Africa/Casablanca (GMT+01:00)

This topic contains 9 replies, has 3 voices.

Last updated by andersN 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#2181461
2-9-2021_GLhQVVtO5C.png
2-9-2021_yOEDWBCuGG.png

Tell us what you are trying to do?
I want to display woocommerce categories conditionally based on generic field checkboxes input.

Is there any documentation that you are following?
Conditional Display for Form Inputs in WordPress: https://toolset.com/course-lesson/conditional-display-for-form-inputs/
Advanced Conditional Display for Form Sections: https://toolset.com/documentation/programmer-reference/forms/cred-conditional-display-engine/

What is the link to your site?
hidden link

#2181785

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL where you added the form with the conditional group and for what field you would like to apply the conditoin?

#2182775

Minesh
Supporter

Languages: English (English )

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

Ok - I got that but what field you want to display when checkbox option with value 1 is selected and what field you want to display when checkbox option with value 2 is selected?

I run a test using the checkboxes generic field where I've added two options:

[cred_generic_field type='checkboxes' field='test-checkbox-field']
{
"default":[],
"options":[{"value":"1","label":"Option 1"},{"value":"2","label":"Option 2"}]
}
[/cred_generic_field]
	</div>

I set the conditional statement to display the field "level" when checkbox "Option 1" is checked.

  
	[cred_show_group if="( $(test-checkbox-field) eq '1' )" mode="fade-slide"]
	<div class="form-group">
		<label for="%%FORM_ID%%_level">[cred_i18n name='level-label']Level[/cred_i18n]</label>
		[cred_field field='level' force_type='field' class='form-check-input' output='bootstrap']
	</div>[/cred_show_group]

I can see its working. Can you please confirm where exactly you are facing the issue? If you have the issue please share the problem URL with access details and mention what field you want to display based on what checkbox option selected.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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.

#2183639

Minesh
Supporter

Languages: English (English )

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

I've set the conditional statement as given under:

[cred_show_group if="($(branchekategori) eq '1')" mode="fade-slide"]	
	<div class="form-group">
		<label for="%%FORM_ID%%_byggeri-anlaeg">[cred_i18n name='byggeri-anlaeg-label']<b>Faggruppe</b>[/cred_i18n]</label>
		[cred_field field='byggeri-anlaeg' force_type='taxonomy' output='bootstrap' display='checkbox']
		[cred_field field="byggeri-anlaeg_add_new" taxonomy="byggeri-anlaeg" type="add_new"]
	</div>
[/cred_show_group]

I checked with the test page you shared: hidden link

I can see its working as expected. Can you please confirm.

#2183769

Thank you very much! Works perfect!

Another question 🙂

If don't want the user to have the option of choosing a parent category - should I just change the taxonomy type to flat instead of hierarchical and if so, how would this change the shortcode above?

#2183775

Minesh
Supporter

Languages: English (English )

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

As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery for the original issue reported.

May I kindly ask you to open a new ticket with every new question you may have. Thank you for understanding.

#2183823

Okay I will open another ticket. Thanks.

#2184019
4-9-2021_hPR5PoOwRQ.png

Okay there was a tab open on another computer and accidentaly saved the old settings.

Tried copying the shortcode you have provided above and nothing happens.

Can you please tell me what I am missing? Sorry for my stupidity 🙂

Support login still works

Thanks

#2185387

Hello there! Minesh won't be available for a couple of days. If you don't mind, I'll continue with you on this ticket.

Well, the code that Minesh has shared needs to be added in the advanced mode of the form's editor. You, currently, copied it inside the user interface of the conditional group. You should switch to the advanced mode and replace the conditional group code with the one that Minesh suggested. Does it make sense?

#2185951

My issue is resolved now. Thank you!