Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Front-end filter logic › Reply To: Front-end filter logic
Good 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_tag
Many 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.