Skip Navigation

[Resolved] Toolset VIew to conditionally display based on custom field

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.

Our next available supporter will start replying to tickets in about 2.99 hours from now. 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 5 replies, has 3 voices.

Last updated by Minesh 1 year, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2651297

Tell us what you are trying to do?
We have products (WooCommerce) that we wish to offer special local delivery by zip code and day. I created a custom field checkbox for this option. It records a '1' if checked. I then have another item (WYSIWYG) in the field group that I wish to display on the screen.

I set up a view. In the view, I told it that it is to be used on products pages. I set the condition for Local Delivery = 1. I then set the dynamic content to be the fields in the aforementioned field group.

The custom field works great. I can go into the product, check the checkbox and edit the WYSIWYG as needed.

The issue I am facing is I want this to display on the individual product page. I only want it to display if the Local Delivery checkbox is checked, which is why I have it set to record a '1' and then set the condition for it to be equal to '1'.

I then put the view on the product php page using Elementor.

I would think it would display, but it is not displaying at all.

Is there any documentation that you are following?
I went through some docs and tutorial vids on the Toolset site as it pertains to views.

What is the link to your site?
hidden link

Note that this is password protected as it is staging. Let me know how to securely share that with you.

#2651375

Nigel
Supporter

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

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

Hi there

I'm a little confused by your description, in particular the role of Views in this, so let me discuss a few things and then you can get back to us with some clarification.

With Toolset there are several kinds of conditional display.

The first comes from Types and relates to custom fields. You can add a condition to a custom field whereby its visibility depends on the value of some other field. This is relevant when entering data (e.g. when editing a post), but has nothing to do with displaying data. In your case you might have the WYSIWYG field only appear on the post edit screen when the checkbox field is checked.

Another kind of conditional display relates to displaying content (or not) depending on, say, the value of some field, which is implemented via the wpv-conditional shortcode (legacy editor) or the Conditional block (block editor). In that scenario, if you had a template to display posts you might use a conditional shortcode to show the content of the WYSIWYG field only if the checkbox field was checked (or you could check if the WYSIWYG field had any content directly). I don't see any role for a View here. (If you are not using Toolset templates for the post type you could add the corresponding markup in an HTML module in your Elementor template or you could set up content in a Toolset content template—not assigned to any post type—and insert that template into the Elementor template.)

#2651935

Your last paragraph is closer to what I am trying to do. Allow me to restate to attempt to clarify.

I want to be able to check a box that will designate a product for local delivery. I have created a custom field for this purpose and have it storing the numeric value of '1' in the db.

I then have a WYSIWYG field where I can type in content. That field is available on the admin product page. I want that field to display on the product screen (pages) if the aforementioned checkbox is checked. I thought to accomplish this I had to use views, but it sounds like I do not have to do so?

Please guide me on how to accomplish this functionality.

#2651965

Minesh
Supporter

Languages: English (English )

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

You can display conditional content either using conditional block or using conditional shortcode.

If your target is to display the conditional field on single post then you can either use conditional block or conditional shortcode and it does not require view.

Please check the following doc for conditional block usage:
- https://toolset.com/course-lesson/using-toolset-conditional-block/
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/

Here is the doc that shows usage of conditional shortcode:
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/

Please let me know if you still find issues where you want to display the conditional custom field.

#2652891

Note from my original question that I am using Elementor. The resources you shared are for the "normal" Gutenberg editor. Is there a way I can accomplish this within the context of Elementor?

#2653125

Minesh
Supporter

Languages: English (English )

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

In case of Elementor, you should create a content template in legacy mod using Toolset from Toolset => Content Templates and add new content template and make sure to create content template in legacy mode (not using blocks) and add the conditionals you want using the [wpv-conditional] shortcode and then add this content template to your Elementor's template using the Elementor's shortcode module.

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/#conditional-output-in-views

If you do not know how to do it, please share admin access details with information on what Elementor template you want to add what conditions.

*** 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.