• mmadden1

    (@mmadden1)


    How can I make a second and third field updated based on the initial field selection?

Viewing 1 replies (of 1 total)
  • Plugin Author WP Smart Widgets

    (@nomade123456)

    Hi @mmadden1,

    If you mean conditional logic (for example, only showing the “Color” filter when the “Clothing” term is selected), that isn’t built into the plugin, but you can achieve it with custom js. Here’s a quick example that hides the Color filter by default and shows it only when the “Clothing” category is selected:

    <script>
    document.addEventListener('DOMContentLoaded', function() {
        const colorFilter = document.querySelector('.flex-wrapper.pa_color');
        if (colorFilter) {
            colorFilter.style.display = 'none';
        }
    
        document.querySelectorAll('.flex-wrapper.product_cat input[type="checkbox"]').forEach(function(cb) {
            cb.addEventListener('change', function() {
                const clothing = document.getElementById('clothing-2dfa79f'); // update ID as needed
                if (clothing && clothing.checked) {
                    colorFilter.style.display = '';
                } else {
                    colorFilter.style.display = 'none';
                }
            });
        });
    });
    </script>

    If you mean something simpler, like showing or hiding child terms when a parent is clicked, you will find this option under each terms group row > Advanced > Toggle Child Terms. Enabling that will let users expand and collapse sub-terms as needed.

    For full conditional display of terms groups, you’d need to add some custom JavaScript like the example above. Let me know if this is what you were looking for.

    Regards,
    Dara

Viewing 1 replies (of 1 total)

The topic ‘Conditional Fields’ is closed to new replies.