Skip Navigation

[Résolu] Taxonomy and conditional logic

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.

Auteur
Publications
#918057
Fascilities-min.jpg

Tell us what you are trying to do?

To simplified I will use very common example of Business Facilities (Hotels) and real-life example from Booking.com (see image). For search/filtration reasons Facilities should be done as Taxonomy (categories), if I'm not wrong. Issue is that depends on selection, some values should to expand to sort of conditional logic and child posts, as well.

1) Simple case on checked value is (mostly two scenarios) FREE/PAID and OnSite/OffSite (see image).

Normal solution will be to use conditional logic and to trigger Selectable Fields, but as far as I know, (Toolset) taxonomy don't support conditional logic.

Workaround is to 'extend' category branch in every situation with additional values level of (ie) Free/Paid. So, (ie) value 'Wine" should be extended with Free/Paid, in next level of categories. Than, somehow, it should to be presented via CFRED (how??? - no idea). However, pay attention, that this 'trick' will not works with images. When value is selected YES, should be offered image upload (see on image small camera icons). That is certainly possible only trough conditional logic.

Is it some other option (as this 'workaround' hardly that can help for next level of problem)?

2) Image clearly shows more complex situation as checked value YES open child post type "Opening Hours".

As I can't see the way how to do it via taxonomy, as well how to trigger child custom post "Opening Hours", please help. How to this?

3) Mix of above two situations, plus REPEATING GROUPS OF FIELDS (or child post type. You can see that with "Add Another Restaurant". Repeating Restaurant is at first look not really different from "Opening Hours", but there is in fact in Restaurant already 'nested' child CPT "Opening Hours".

Is there a similar example that we can see?

Yes, Booking.com, Expedia, .....

What is the link to your site?

I can post it in private message.

#918178

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

Q1) Is it some other option (as this 'workaround' hardly that can help for next level of problem)?

Where do you want to implement "conditional logic and to trigger Selectable Fields"?
If it is in WordPress front-end with Toolset form, please check our document:
https://toolset.com/documentation/user-guides/cred-conditional-display-engine/
Variables are the field inputs. You can use custom fields and taxonomy as variables.
If it is in WordPress admin side with Types plugin,
Please check our doucment:
https://toolset.com/documentation/user-guides/types-custom-fields-conditional-display/
screenshot
hidden link
There is a tab "Taxonomies", use it you can setup the conditional display logic based on taxonomy.

Q2) As I can't see the way how to do it via taxonomy, as well how to trigger child custom post "Opening Hours", please help. How to this?

In wordpress admin side, there isn't such a feature.
In front-end with Toolset form, form within form is not allowed by HTML standard
https://stackoverflow.com/questions/3430214/form-inside-a-form-is-that-alright

So user needs to create the "Hotels" post first, then in the single "Hotels" post, use wpv-conditional shortcode to check the taxonomy value and display another form for creating "Opening Hours" post
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

Q3) Repeating Restaurant is at first look not really different from "Opening Hours", but there is in fact in Restaurant already 'nested' child CPT "Opening Hours".

Same as Q2), user need to "Hotels" post first, then create "Restaurant" post, finally create "Opening Hours" post

#918358

Please be kind and try to stick answers to area of question (what is here - Types/backend), as involvement of CRED and View just make confusion (for me), as I try to establish correct structure of posts. If you want to explain that some thinks can't and/or should not to be handled by backend, than that is complete OK to write me in reply how I can later to handle that in CRED/VIEW, but please underline how that is not necessary to set it with Types, as can be handled by CRED/View.

Q1) Please try to be more pragmatic in concrete example (like you was in answers on second and third questions). So, for me is not clear. Do you said that I should to create ONE SINGLE FIELD (ie Free/Paid) for entire post and than that one single field can be triggered conditionally in backend , depending of taxonomy values (so, that single field can be used many times - each time same field for different taxonomy values can be used)? If it is, than operator must be OR, correct?

Actually, I will try to do that in couple of hours later today (time zone issue). If it will work, great.

Q2) As I already have solved 'Opening Hours' (thanks to Nigel), I will also add it and try to follow you.

Q3) Same like above.

Can you in meantime just open private link, that for today late I can post you links and credential for test site if I will be faced with particular issue in any of scenario. Than you will be in position to see is it there anything wrong done if I found some problems (problem for me). In meantime just please answer on Q1 about Free/Paid, to make me easier to go further.

#918905

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Ljuba

I just posted a lengthy reply in the other thread which I think covers what is asked here.

If it's okay can we just close this one and if you have comments you can reply in the other thread?

#919113

As I wrote (and you noticed), here is point in structure (Types) and not on CRED and/or View.

1) As I have Formidable Pro developer license, it is certainly in serious consideration to use it (and most likelly I will), but I'm still not in stage to seriously think about it. Here is important only to note that with Formidable is very easy to force Posts registration order (to make 'chained' (nested) Forms.

2) I think that I'm quite flexible and when you open link provided in other topic, you will see how I basically completely redesigned structure for purpose to force taxonomy and to avoid conditional logic. Price was, some more post types and complete removal of options from Booking.com:

== Tipo de disponibilidad (Gratis/De pago)
== ¿Dónde está ubicado?(En el establecimiento/Fuera del establecimiento)
== Restricción por edad del niño
== Foto

3) Destino now have for childs = Sitio, Lugar (no further childs), Eventos (classic - I will not extend it) and Negocios. But I needed to add some 'universal' child post types, as Location and Opening Hours (they will be child in all post types). Here is particularly important to note how is possible that some Negocio have more than one Location (other posts as well, but to stick to Negocio).

4) Further, Negocio is divided in Alojamiento, Gastronomia, Servicios comerciales and Compras, but Negocio also have Special Child Post Type - 'Deals' (nothing more now about it in topic). You have idea what it will do.

5) All 4 Negocio 'normal' childs have specific (same kind of) post type (rooms, menu, services, products).

So, my 'flexibility' was that I will basically force clients to instead to drop some (ie) services within 'facilities' (ie Beauty Salon), as it is done in Booking.com, they should to register SECONDARY BUSINESS (will be possible to be without the business name), as it is in fact secondary business as it has particular Opening Hours and obviously is paid service, as well. Most known example is Hotel (PRIMARY BUSINESS) with 2 Gastronomy businesses (restaurant and bar), 2 or more Service business (ie SPA and Swimming Pool and Laundry) and (ie) Gift Shop (Compras).

ThAt's why I have common Field Groups for Negocio and specialized Fields and taxonomies per 4 child post types (business types).

6) That's why I created also Piscina as child of Alojamiento and Servicios comerciales. If it is within Alojamiento, it will be Gratis and contrary, must be separate business. As there is no real life example how anybody offer free SPA or Beauty Service, I don't think that I need another type of posts. However, I added taxonomies of some common possibly free SPA and/or beauty faxcilities. So, if taxonomy option is checked, it is free, otherwise should be opened SECONDARY BUSINESS (as it is).

7) Final 'price' is that previous 'Opening Hours' should be now somehow to be rewritten and to became 'Schedule' (Horario), to say - much more flexible and universal (to be possible to use it everywhere), or maybe not, as QUESTION IS:

==> For now, I have 17 custom post types (but many fields will 'migrate' to taxonomies) and I estimate that I will be capable to make it with 23 - 30 CPT. Is it too much vs performances?

Example, with with flexible Location CPT (small conditional logic) I will save a lot of the fields, but will be much more posts.

Another example is Horario. If I will slightly more extend it, it can be used for anything and everywhere, but will be also much more posts.

8) Posts registration order. As I started reply, to finish it. Client will basically first finish all fields regards the Negocio and as form will much most likely will be 'Tabbed', by Continue will start to fill secondary post and so on. QUESTION IS:

What will be the best way to get choice for PRIMARY BUSINESS TYPE (one of 4)? In other words, how to force opening of specific child post type (and not to get all available child post types). No need for details, just general answer. I guess, that it can be done via CRED (or Formidable) by conditional logic within CRED (Formidable), but ....

#919246

Now is entire and most complicated line Destinos > Negocios > Alojamientos > Habitaciones roughly done with additional CPT's (Ubicacion, Horario, Piscina). Roughly mean that it is enought that you can see the concept.

I can't see any further crucial issue. All looks fine (to me, at first look). However, some points are not clear for me how to do.

1) In Location CPT I set basic fields (taxonomy administrative division should to be added also) and here is for me not clear exactly how to conditionally call that 'Location child CPT' ie from 'Tax' Field Group. I mean - should I add to Location CPT additional field 'Location Type' (Billing address, Taxes address, Accomodation address, Restaurant address, ....) or I can freely let it for CRED and View HTML 'titles masking'? I guess that I need to do it only if I have scenario with more than one Location within same parent CPT (at least, one possible scenario), right?

2) Now you also can understand much clear what was idea with Opening Hours topic. Should we open new ticket to for help vs special days (ie how to set hollidays, and such thinks)?

P.S. - I will restore your 'opening hours' codes today late (so, we can keep monday).

3) MAIN How to force PRIMARY BUSINESS TYPE? (Is it Types or CRED issue? I f that is CRED, than I know how.)

#919982

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Ljuba

Sorry for delays replying, the queue is extremely busy and we have a couple of the team on vacation.

7) Posts, lots of posts.

WordPress is designed around posts and is optimised for querying posts and is able to handle large sites with very many posts.

Your situation is a little different because you are using Toolset post relationships, but the recent update to Types 3 uses indexed custom database tables for these with the clear intention of improving performance compared to the Types 2 way of storing relationship information as post meta. You have to store this data with these connections in one form or another, and Toolset post relationships have been designed to be as efficient as possible.

8) CRED forms publish one and only one type of post.

You have two options. One is to create different forms to each post type and then the key is linking to the correct form. You might have a dropdown to with links to the four different forms (on four different pages, or one page with a URL parameter used in wpv-conditionals to display the right form).

If the four forms are basically the same apart from which post type is published, the alternative would be to have one form that publishes whatever and include a generic select field in the form for which kind of business is being added and then use a CRED API hook to modify the post type after the form has been submitted.

I'm not sure which is the current version of your site you are working on.

I visited new.canoaturinfo.com but it doesn't have very much set up compared to what you described above.

I was trying to take a look so I could better understand Q1 in your second update above, I had trouble following that (end of day, brain is tired).

Yes, could you please open a separate ticket about the opening hours.

#919993

==> Thanks for answer on post type numbers and forms.

=> I thought that you figured how it is not a new.canoaturinfo.com and now is negocios.canoaturinfo.com.

==> I will open new for opening hours and please take it you as it is completely grounded on your previous work, only made it more universal vs possible usage purpose.

==> For this topic remain only answer on question what way to use to set (determinate) main child post type (and how to do it) - taxonomies or field type?

To resume (to make it easier to you to not search topic). I have Negocios CPT with 4 child CPT's (Alojamiento, Gastronomia, Servicios, Compras) as business types (so, there is more child posts, like opening hours or piscina, but they not count here).

There is 'normal' and usual scenario that one business have more than one 'activity' (business type) and/or more than one locations for each business type. Locations of business types are obviously subject of repeating child CPT (ie - Gastronomia if there is more than one Restaurant location). Here also remain unclear for me how to limit it (I know that I can limit in Relationships number of child posts, but here is other and more complex issue, as I want to be able to 'dynamically control' that number, but for that I should open additional ticket).

So, when client finish filling and submission of fields related to parent post Negocios, he (I think) also should already to have in some way selected child post type of main business (trough field or taxonomy) and that value somehow should to determinate what child post will be set for main business type. You can see that I already created seletable field in Field Group of Negocios - 'Sobre negocio' (field is 'Tipo de negocio'). Than he (client) probably also should to have additional field with question - 'Do you want to add another business type?'. From this logic, looks that it must be fields and not taxonomy, but in any way, I don't have idea how to set it.

I here think that it should to be possible to do within Types, but maybe is that subject of CRED, as you basically pointed on your answer related to forms. Whatever, I hope so how question is clear.

If your answer is that it is as you explain within forms explanation, just please explain me how to set 'Do you want to add another business type?' and how to limit those numbers of business types (that's eventually also somehow answer on limitation of total number of post types - related to business locations) trough such CRED question, specifically with taking in mind that numbers will be connected to the type of account (free, basic, extended, ....).

#920041

Actually, my bad.

Another business or another location are same think (only view/content template is different).

#920445

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Sorry to go backwards slightly, but...

Say you have a hotel.

You add a new negocio post for the hotel which is essentially a container for the businesses a hotel might offer (traditional businesses such as two restaurants, a paid spa etc.), but what about alojamiento?

It seems odd that you might add a hotel, and then have to add a child alojamiento negocio that is basically the hotel.

Likewise, if your business is a restaurant, you add a negocio post for the restaurant, and then you have to add a child post for gastronomia, which is basically the restaurant business.

It seems more like they are all just negocios with a different classification (e.g. business type taxonomy with terms 'alojamiento', 'gastronomia', 'services', 'compras').

Then the problem is that relationships currently don't support connections to the same type (i.e. you can't make a relationship between one negocio post which is the hotel, and a second negocio post which is its restaurant, a third which is its salon, etc.).

You can make standard WordPress hierarchical posts, though (like pages, with a parent negocio post and child negocio posts) for which you can add filters in Views queries etc.

What do you think about that?

#920499

1) I clearly (was easy to do) separated common features (fields and taxonomies) and assigned it to Negocios, from specific features to any of 4 business types.

2) They are not the same (4 types) as there are the bunch of specific features, plus specific child posts (also with specific features). Example

Hotel ==> Negocios > Alojamientos > Habitaciones > Camas (all CPT)
Restaurant ==> Negocios > Gastronomia > Menu

3) If you suggest to drop out Negocios CPT and to assign common features to 4 CPT's, no problem (there is some logic). However, count that your scenario is not common from real life (hotel don't have another hotel inside).

4) Business (Negocio) is also by law 'formal legal unity' with registration permits to do some types of the business (most registering almost everything). So, Negocio is 'deal' with that (common, legal) part of the identity. In Ecuador is ILLEGAL ANY KIND OF COMMERCIAL ACTIVITY WITHOUT TAX NUMBER. In other words, you cannot either to rent your own private room without RUC (tax) number (individual or company). It looks like (example)

Negocios ==> is Company CIA LTDA / or Ljuba as private person with RUC (and there are bunch of the fields and taxonomies - common for Booking.com, Yelp!, OpenTable, ....).

So, believe or not, accommodation don't have anything with gastronomy, and not just legally, despite the fact how Restaurant is on the same lot where is Hotel (or inside of the Hotel building). Everything is separate, including accounting.

In real life it is always about legal entity with different business locations. Sometimes is two location of same business type (2 restaurants) and sometimes are two locations with different business (nobody sleep in restaurant, sorry, bad joke, but illustrative). Maybe will help if you open Dashboard of hidden link.

TO CONCLUDE

a) If I drop out Negocios and assign common fields to 4 CPT's (or leave it as it is), I just see that more complicated, as now, it should to look somehow similar to 'nesting' Rooms CPT to Alojamiento (and Beds to Rooms). Now, I need to 'nesting' 4 CPT's types to Negocio.

Hotel and restaurant don't have relationship between them, just with Negocio (as they are in any single sense separated).

Here only remain question > How to control child CPT's? (set what is primary/principal child CPT, numbers of allowed CPT's per Negocio, ....)

b) Here is in any way issue of control of the child CPT (menu, products, or whatever), as NOBODY WILL ALLOW UNLIMITED NUMBERS. Issue is how to control that number 'dynamically' (per paid membership level). Statically is easy to limit number of child posts, system wide, in Relationship wizard, but how to do it dynamically (per membership level)???

P.S. To repeat, everything works fine (I sort of tested), issue is that I can't to start 'design' until I don't finish structure concept. 'Nesting' some business type within Negocio is 101% same as 'nesting' rooms within hotel, or beds within room.

#920920

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

OK, so sticking with the example of a hotel, at a minimum a hotel would have a negocio post (for the legal entity managing the hotel) and then an alojamiento child post for the actual accommodation.

So in terms of workflow, your users add the negocio post.

At which point before specifying what kind of business(es) they are adding, they could add any one (or multiple) of

- alojamiento
- gastronomia
- servicios
- compras

and the issue you have is that you don't want them to see

- add alojamiento
- add gastronomia
- add servicios
- add compras

you want them to see

What kind of business? ( alojamiento | gastronomia | servicios | compras )

and depending on which they choose (e.g. alojamiento) they would see

- add alojamiento details

and at some point also

- add another business

If this were happening just with Types in the backend then you would be adding the child posts using the normal UI which means you would have sections visible for each of the four types of negocios—what I said you don't want above.

You can't conditionally display those in the same way you can conditionally display certain individual fields based upon the choice in some select field, for example. For that you would need some custom JS enqueued on the appropriate backend post edit screens.

If it makes sense to organise your post types in the way you describe (negocios as parent of the four different business types) then you should continue with that. Using a select dropdown to specify what kind of business this is (which determines what kind of child post type will be added) is just an implementation detail. If your clients will be adding this content on the front-end then you only need concern yourself with the implementation in front end forms, where you would also be able to impose some logic about how many child posts could be added.

#920931

Now, you get it right (mainly).

User first MUST to register business (with details) and just after that can go further to register his PRIMARY BUSINESS ACTIVITY (and than eventually secondaries). I already created Field Group 'Sobre Negocio' and part of the group is selectable 4 type business field (but zero functionality, as I don't need it to display and there is no yet conditional logic, as that is the topic).

For 4 types, I didn't used Repeatable Groups (native choice) for know reasons. Field Groups within Negocio can't be used as i don't see how to repeat it. Only remaining choice was child post type, but with question of this topic - how to control it (in some programmatic way)?

If answer is that it can be done via CRED (via selectable field of Business Type)- fine (no need details now as question was about Types structure). Answer is > number of child posts can be controlled via conditional logic in CRED (that's how I understood your answer).

However, question is (slightly) more complicated as it is about sort of 'layered' 'quiz'. So called 'first loop' of conditional logic should to determinate PRIMARY business type, but after fill the content, should to come 'second layer' > 'Do you want to add another business activity (type or location)?'. Probably all can be solved via CRED conditional logic (as same questions will be about rooms, beds, meals in menu, products in catalog, ....).

ENTIRE POINT OF TOPIC is how to make entire above described process dependent of membership level (plan)? Classifieds will not solve it. I I guess that again some selectable field (what I don't created yet) of available plans should to work here (again in CRED), but how?

Customer choose 'Extended plan' (ie business with totally 3 BUSINESS ACTIVITIES). I guess than here again come some kind of CRED JS code (similar as Christian Cox made me for limitation of repeated images for gallery). However, such choice also should to open process of payment of the 'selected plan' and to be active just after payment is done (so, client can add additional activities only after confirmed payment). In other words, entire intial registration process is FREE PLAN and that it should to be possible to upgrade.

So, this is my entire topic dilemma how to set structure of the Types. If that will work, we can close the topic (as specific CRED questions will be opened ticket when I will do it).

#921361

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Reading through your last response, yes, I think the types part is set up in the only way it realistically can be given the various limitations that have arisen during the discussions.

The individual parts can be set up with CRED using custom code for validation to limit the number of child posts that can be added according to the role of the user (the role being set according to their payment plan), but recall when thinking about a CRED solution that one CRED form can only publish (or edit) a single post. Adding child posts from the parent form is not supported, and I know that it will take time to implement, meaning a custom handler for a single many-faceted form (not necessarily a CRED solution) may be your best option.

Note I am about to start a week's holiday. I will answer your horario ticket before I go but I won't be around for new threads for a while.

#921386

1) About CRED, no problem, it could be set in several ways (ie Tabs).

2) Holidays. Great for you, bad for me (not too many good supporters), but that's the life. Happy holidays.

3) Before you go, let me make final (biggest) point of topic (I didn't want to involve it from begn to not confuse you).

I'm from begin actually worried only regards Content Templates (Views). In real life exists, literally unlimited number of combinations of number and type of business ('vertical and 'horizontal' classification, but actually the same, as one location is always one business type). Thinks are slightly more complicated as I work with Genesis/Elementor (read > templates).

So, I want to have so called 'static' (one time plan payment) and 'dynamic' plans (basically, probably could be set via Classifieds and expiration date - not the part of topic, but important to understand). Dynamic plans contain services paid on time basis (ie Booking functionality, Home delivery, ....) and they should be Views conditionally displayed (when 'paid' content/view is not paid, will be replaced with 'secondary content).

Problem (part of topic, as Types structure depends on it) is 'static' plans. I planed 5 plans (one is Free), plus sort of 'enterprise' (unlimited businesses), what mean 5 (+ one) Content Templates (Elementor Templates???). Four paid templates should to have limitations of numbers of businesses (free plan is basically part of Negocios without child posts).

Easy (simple) solution is that administrator manually switch template for current client after received payment (as it is lifetime one time payment). It should be specifically easy to do via Elementor (nice and simple conditional logic for templates).

Is it the way to do with Toolset in some sort of programmatic (automatic) way (I guess, Views conditional logic)? No needs for detailed reply.