Skip to content

Instantly share code, notes, and snippets.

@sachyya
Last active March 21, 2024 10:36
Show Gist options
  • Save sachyya/86e0f7998352fdcb2ac53bb81c02bee3 to your computer and use it in GitHub Desktop.
Save sachyya/86e0f7998352fdcb2ac53bb81c02bee3 to your computer and use it in GitHub Desktop.
Pass preselected filters in Typesense search for WooCommerce
( function() {
window.addEventListener( 'load', function() {
// Typesense search for WooCommerce
// SchemaFilterName is the name of the facet defined in the schema
// tsfwInstance is the global variable passed for customization
// ts_woo_main_search is the unique identifier which can be changed from shortcode using unique_id attribute
tsfwInstance.ts_woo_main_search.helper.addDisjunctiveFacetRefinement('schemaFilterName', 'Tshirts').search();
tsfwInstance.ts_woo_main_search.helper.addDisjunctiveFacetRefinement('schemaFilterName', 'Blue').search();
} );
}() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment