Skip Navigation

[Resolved] Hide empty dropdown

This support ticket is created 6 years, 2 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.

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.

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 4 replies, has 2 voices.

Last updated by Minesh 6 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1101737

Hello,

I need some help customizing a filter for my woocommerce views archive with the following 2 issues

1- I already created the filter inside the views, and it works fine, there are differents dropdowns, one dropdown for each attribute that my product may have according to its category.

But I would like to hide all empty dropdowns that dont belong to the category im seeing.

I was following the conditional documentation but it is not working.

For developing porpose I remove all filters and leave just one for testing.

As you can see in the following link there is an empty dropdown:
hidden link

And then it its full in the following link:
hidden link

2- Is it possible to create a search field inside a dropdown or selectbox to filter the options inside of it?

Best regards,

#1101796

This is the filter I need to conditionate

<div class="form-group">
	<label>[wpml-string context="wpv-views"]Product Diámetro Externo[/wpml-string]</label>
	[wpv-control-post-taxonomy taxonomy="pa_diametro-externo" type="select" url_param="wpv-pa_diametro-externo"]
</div>
#1102443

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

1- I already created the filter inside the views, and it works fine, there are differents dropdowns, one dropdown for each attribute that my product may have according to its category.
Well - the only way to hide the empty drop-down is using the jQuery code.

Please check following link that may help you:
=> https://stackoverflow.com/questions/24248597/jquery-hide-dropdown-if-all-option-value-are-empty

2- Is it possible to create a search field inside a dropdown or selectbox to filter the options inside of it?
==> No, there is no such feature exist to convert the dropdown to select2 box.

#1102565
dropdown-with-search.png

Hello Minesh,

thanks for helping me.

1- It worked, but when selecting an option from the available dropdowns ajax refreshes and displays all the hidden attributes, please can you help me solve this.

2- Then, is there an option to search by term inside of the dropdown? Something like the image I'm attaching.

#1104269

Minesh
Supporter

Languages: English (English )

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

1- It worked, but when selecting an option from the available dropdowns ajax refreshes and displays all the hidden attributes, please can you help me solve this.
==> Well - you can use the view's Javascript Front-end Events.

When you visit view's Filter section's JS box - you will see a button "Frontend Events". When you click it it will allow you to choose ajax callback events for parametric search.

Refer this image:
=> hidden link

For example:

jQuery( document ).on( 'js_event_wpv_parametric_search_form_updated', function( event, data ) {
	/**
	* data.view_unique_id (string) The View unique ID hash
	* data.view_changed_form (object) The jQuery object for the View form after being updated
	* data.view_changed_form_additional_forms_only (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-form-view] shortcode
	* data.view_changed_form_additional_forms_full (object) The jQuery object containing additional forms from other instances of the same View inserted using the [wpv-view] shortcode
	*/
     /// Add your custom JS code here 
	
});

2- Then, is there an option to search by term inside of the dropdown? Something like the image I'm attaching.
==> No - there is no such option available.