Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Front-end filter logic
- This topic has 8 replies, 2 voices, and was last updated 4 years, 9 months ago by
Ernest Marcinko.
-
AuthorPosts
-
August 29, 2021 at 2:42 pm #34395
willfaulds59
ParticipantSetup as attached.
I cannot get the “All of the selected terms must match, exclude unselected (default)” to work as expected.
Setup on WooCommerce products using product_tag taxonomy.
August 29, 2021 at 2:45 pm #34397willfaulds59
ParticipantOn the Front-End the filters appear as expected.
A single product tagged with TagA, TagB and TagC will however only show when all 3 tags are selected.
I have tried multiple combinations of settings but cannot find the correct settings so that:
TagA selected = only product with TagA are results (ignore other tags).
TagA and TagB selected = only product with TagA AND TagB are results (ignore other tags).-
This reply was modified 4 years, 9 months ago by
willfaulds59.
August 30, 2021 at 9:38 am #34408Ernest Marcinko
KeymasterHi,
Change this option: https://i.imgur.com/Y7Be135.png
By default the unchecked checkboxes are treated as exclusions. This should resolve that.August 30, 2021 at 12:29 pm #34415willfaulds59
ParticipantThank you Ernest,
This still doesn’t quite give the behaviour I am looking for.
TagA selected = only product with TagA are results (ignore other tags).
TagA and TagB selected = only products with TagA AND TagB are results (ignore other tags).The settings you suggest give
TagA and TagB selected = any products with TagA or TabB are results
August 30, 2021 at 12:42 pm #34416Ernest Marcinko
KeymasterCan you try the third option from that same drop-down? It should be very close to your requirements.
August 30, 2021 at 5:56 pm #34419willfaulds59
ParticipantThank you Ernest!
I swore I had checked that option… but it does seem to be working as I wanted. Perfect.
I have a last question about the theme chooser.
https://documentation.ajaxsearchpro.com/theme-options/theme-chooserThe documentation states you can use it without choosing a theme but I cannot seem to unload the previously selected theme.
If as in the attached screenshot I choose “Select” the previous theme is still loadedAugust 31, 2021 at 6:49 am #34434Ernest Marcinko
KeymasterGreat 🙂
It was phrased incorrectly in the documentation, I will correct that. By that we meant, that you can make changes to the initial layout (which is by default the “Simple red vertical” theme). The theme chooser is a baseline of pre-defined layouts, which you can load and then customize basically.
September 1, 2021 at 3:17 pm #34474willfaulds59
ParticipantGood to know, thank you Ernest.
I would love to see a future option of a very VERY bare-bones theme for easy integration with other/custom themes.
I am now working on adding a radio front-end filter for some product tags that are cannot exist on the same product. e.g. Alcoholic and Non-alcoholic. I can’t quite get the code to work.
I have 2 hopefully simple questions
1/ Can I add a filter to appear within an existing fieldset? E.g. underneath “Filter by Product tags” created in the admin back-end?
2/ Can you help correct the below example to correctly search with product_tagMany thanks,
Would you be interested in WooCommerce related write-ups and snippets when this project is complete?
//from: https://knowledgebase.ajaxsearchpro.com/frontend-filters/frontend-filters-api add_action('asp_pre_parse_filters', 'asp_add_my_own_filters', 10, 2); function asp_add_my_own_filters($search_id, $options) { if ( $search_id == 1 ) { // Radio /* $type (string) - The filter type, can be: taxonomy $label (string) (optional) - The filter box header label $display_mode (string) (optional) - The display mode of the filter values: checkboxes, input, slider, range, dropdown, radio, dropdownsearch, multisearch $data (array) (optional) - Additional data, that may be required within the template for this filter depending on the $type and $display_mode Check the examples below for the usage. */ $filter = wd_asp()->front_filters->create( 'taxonomy', null,//'Filter testing' // Type: dropdown, dropdownsearch, multisearch or radio 'radio', array( 'taxonomy' => 'product_tag', ) ); $filter->add(array( 'label' => 'Alcoholic', 'taxonomy' => 'product_tag', 'id' => '21',//tag_id stupid no the the slug 'selected' => false, )); $filter->add(array( 'label' => 'Non-alcoholic', 'taxonomy' => 'product_tag', 'id' => '22',//tag_id stupid no the the slug 'selected' => false, )); $filter->selectByOptions($options); wd_asp()->front_filters->add($filter); } }-
This reply was modified 4 years, 9 months ago by
willfaulds59.
-
This reply was modified 4 years, 9 months ago by
willfaulds59.
September 2, 2021 at 8:51 am #34490Ernest Marcinko
KeymasterHi!
To add new values to an existing taxonomy term filter, use this one:
add_filter('asp_pre_get_front_filters', 'asp_change_a_filter', 10, 2); function asp_change_a_filter($filters, $type) { foreach ($filters as $k => &$filter) { if ( $filter->field() == 'product_tag' ) { $filter->add(array( 'label' => 'My custom product tag', 'selected' => false, 'id' => 123 )); } } return $filters; }Of course the tag ID needs to be an existing tag ID, the label does not matter.
-
This reply was modified 4 years, 9 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.