Hello,
Tell us what you are trying to do?
I created a set of measurement custom fields with types, different for each taxonomy in my store, I would like to create a conditional between filter (min, max) that show products according to this input. But I would like to hide all the filters that aren't available in the preselected taxonomy (archive page), it is mandatory to select a taxonomy to display products.
Is there any documentation that you are following?
Tried with this:
https://toolset.com/forums/topic/conditional-filter-fields/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
What is the link to your site?
hidden link
Best regards,
Hi Diego,
Thank you for contacting us and I'll be happy to assist.
We’ll need temporary access (WP-Admin and FTP) to your site, to see how the custom fields, taxonomies, and the products are currently set up.
This will allow us to offer better help and suggest the best way forward for those conditional filters.
Your next answer will be private which means only you and our support team will have access to it.
If you’re going to share the access details for the live/production website, it is very important that a complete backup of your database and website has been made.
Please let us know if you have any further information or questions.
Regards,
Waqar
Hi Diego,
Thank you for sharing the access details.
From looking into the custom fields and taxonomies set up, I can confirm that the best way to show only relevant filtering fields, based on selected taxonomy would be by using custom JavaScript.
( as explained by Nigen in another support thread: https://toolset.com/forums/topic/conditional-filter-fields/ )
You can group your relevant filtering fields into special wrappers, e.g.
<div class="filtering-field-group filtering-field-group-1">
code for the filtering fields related to taxonomy term 1
</div>
<div class="filtering-field-group filtering-field-group-2">
code for the filtering fields related to taxonomy term 2
</div>
....
Next, you can add some custom Script to first hide all the field groups and then show them only when the relevant term is selected from the taxonomy drop-down ( Vehículo ):
(function($) {
$(document).ready(function() {
// hide all filtering field groups on page load
$('.filtering-field-group').hide();
$('select[name="wpv-aplicacion"]').change(function() {
var current = $(this).val();
if (current == 1) {
$('.filtering-field-group-1').show();
$('.filtering-field-group-2').hide();
} else if (current == 2) {
$('.filtering-field-group-2').show();
$('.filtering-field-group-1').hide();
}
});
});
})(jQuery);
Similarly, you can extend the filtering groups and custom script, to accommodate for more taxonomy terms.
I hope this helps! Please let us know if you need any further assistance.
Thank you Waqar for your help.
Please can you tell me how could I check if there are any value into a custom field of any product inside the archive. So i can hide it if not. Or should I create a taxonomy which I could check?
Hi Diego,
Thanks for writing back.
To check if the archive list contains any product that is attached to a particular custom field or not, complex AJAX script will be required, so that its relevant filter can be hidden/shown.
Unfortunately, to achieve this you'll need custom programming work which is beyond the scope of our support.
At this point, I would suggest you consider contacting one of our certified partners from this link:
hidden link
You will get the custom assistance you need to get on with your project.
Taxonomy based filtering of products on archive views is a builtin feature and you can group your similar products using a new taxonomy and add its filter on your archive (which won't require addition script).
If I can be of any further assistance, please let me know.
regards,
Waqar
I solved the CF validation creating a taxonomy with the same information as the CF and then created a condition to validate the taxo, if empty then hide the hole div.