Skip to main content

Advanced JavaScript customisation

Start with the settings in Customise the design. If you need changes that are not available there, override supported storefront configuration through JavaScript.

warning

These options affect the live search experience. Test changes on a duplicate theme before applying them to your production storefront.

Add JavaScript configuration

On page load, settings configured in the app are exposed on the window.HSData object.

Add an Essential script to the page head in BigCommerce Script Manager. The following example changes the storefront search placeholder.

<script>
window.HSData = window.HSData || {};
window.HSData.translations = {
"search_placeholder": "What are you looking for?"
}
</script>

BigCommerce Script Manager entry containing a Hyper Search HSData override

Customisation example

Translate the search experience

You can modify the text used within the search experience by overriding the window.HSData.translations object.

<script>
window.HSData = window.HSData || {};
window.HSData.translations = {
"apply": "Apply",
"clear": "Clear",
"next": "Next",
"previous": "Previous",
"per_page": "Per Page",
"quick_view": "Quick View",
"was": "Was",
"now": "Now",
"and_up": "& up",
"recent_searches": "Recent searches",
"sort_by": "Sort by",
"results_for": "Results for",
"all_products": "all products",
"view_all": "View all",
"no_products_found": "No products found",
"why_not_try": "why not try",
"top_searches": "Top searches",
"show_more": "Show more",
"show_less": "Show less",
"search_placeholder": "What are you looking for?"
}
</script>

Configuration options

The following is a full list of configuration options that can be defined.

info

The app provides these values automatically, and many are available in the app settings. Override only the values you need.

HSData

FieldTypeNotes
app_overlay_idstringDOM ID of the overlay container.
app_suggestions_idstringDOM ID for search suggestions.
app_results_idstringDOM ID for search results.
app_wrapperstringDOM ID of the main wrapper element.
search_query_paramstringQuery string parameter for the search term.
search_option_paramstringQuery string parameter for search options.
search_pathstringPath used to trigger search.
hyper_search_cookiestringCookie name used for session or tracking.
is_hidden_classstringCSS class used to hide elements.
catalog_entitystringEntity name for catalog search.
content_entitystringEntity name for content search.
horizontal_filterstringCSS selector for horizontal filters.
vertical_filterstringCSS selector for vertical filters.
collapsed_filterstringCSS selector for collapsed filters.
is_searching_classstringCSS class to show during search loading.
api_domainstringBase domain used for API requests.
store_hashstringBigCommerce store hash.
channel_idstringBigCommerce channel ID.
typesense_configTypesenseConfig | nullConfiguration for Typesense search engine.
search_configSearchConfig | nullSettings for different search collections.
search_filtersSearchFilters[] | nullArray of available filters.
searchable_fieldsSearchableFields[] | nullFields that can be searched.
search_sort_ordersSortOrder[] | nullSorting options for search results.
search_settingsSearchSettings | nullSettings for search display and behavior.
search_product_cardstringCSS selector for the product card.
search_inline_product_cardstringCSS selector for the inline product card.
search_contentstring | nullOptional HTML for search content results.
zero_results_contentstring | nullOptional HTML for zero results message.
active_currency_codestringCurrent store currency.
default_currency_codestringDefault store currency.
currency_fieldsstring[]Fields that support multiple currencies.
customer_idnumber | nullID of the logged-in customer.
customer_group_idnumber | nullGroup ID of the logged-in customer.
default_sort_bystringDefault sorting field.
default_desktop_filterstringDefault filter view for desktop.
default_mobile_filterstringDefault filter view for mobile.
sort_order_countstringUsed to configure sort order display.
facet_type_groupstringDefines groupings for facets.
translationsTranslations (optional)Custom text translations for UI.
showOverlay() => void (optional)Function to show the overlay.
hideOverlay() => void (optional)Function to hide the overlay.
default_image_urlstring (optional)Fallback image URL for products.

SearchableFields

FieldTypeNotes
fieldstringField that is searchable.
prioritynumberPriority of this field when ranking results.

SearchCollection

FieldTypeNotes
collectionstringName of the Typesense collection.
entitystringEntity type being searched.
paramsTypesenseParamsSearch parameters.

SearchConfig

FieldTypeNotes
catalogSearchCollectionSearch configuration for product catalog.
contentSearchCollectionSearch configuration for content.
top_searchesSearchCollectionSearch configuration for top searches.
redirectsSearchCollectionSearch configuration for redirects.

SearchFilters

FieldTypeNotes
display_namestringLabel to display for the filter.
fieldstringField to filter on.
facet_typestringType of facet (e.g., checkbox, slider).
sort_orderstringOrder in which the filter appears.

SearchSettings

FieldTypeNotes
integration_method'suggestions' | 'overlay'Integration style.
products_per_rownumberNumber of products displayed per row.
desktop_filterstringDefault desktop filter display type.
mobile_filterstringDefault mobile filter display type.
pagination_default_valuenumberDefault pagination size.
pagination_optionsnumber[]Available pagination options.
pagination_typestringType of pagination UI.
container_widthstringCSS value for container width.
mobile_breakpointnumberPixel value for mobile breakpoint.
limitnumberMaximum number of results.
filter_limitnumberMaximum number of filters.
toggle_button_targetstringSelector for filter toggle button.
overlay_position_targetstringSelector for overlay positioning.
category_filter_typestringType of category filtering.
secondary_sort_orderstring (optional)Optional secondary sort order.

SortOrder

FieldTypeNotes
display_namestringLabel shown for the sort option.
sort_orderstringSort logic applied (e.g. 'price:asc').

Translations

FieldTypeNotes
applystringLabel for apply button.
clearstringLabel for clear/reset button.
nextstringLabel for next page.
previousstringLabel for previous page.
per_pagestringLabel for per-page selector.
wasstringPrefix for showing previous price.
nowstringPrefix for showing current price.
and_upstringLabel for filters like '4 stars and up'.
recent_searchesstringHeading for recent searches.
results_forstringPrefix for search result header.
no_products_foundstringMessage for zero search results.
why_not_trystringFollow-up suggestion heading.
top_searchesstringHeading for top searches.
show_morestringText for show more toggle.
show_lessstringText for show less toggle.

TypesenseConfig

FieldTypeNotes
nearest_nodeTypesenseNode | nullPreferred Typesense node for faster querying.
nodesTypesenseNode[]List of fallback Typesense nodes.
api_keystringPrivate API key for Typesense.
product_api_keystringAPI key used for product-specific queries.

TypesenseNode

FieldTypeNotes
hoststringHostname of the Typesense server.
portstringPort number for the Typesense server.
pathstringOptional path prefix.
protocolstringProtocol used, typically 'http' or 'https'.

TypesenseParams

FieldTypeNotes
query_bystringComma-separated list of fields to query.
per_pagenumber (optional)Number of results per page.
highlight_full_fieldsstring (optional)Fields to highlight.
filter_bystring (optional)Filter expression.
group_bystring (optional)Field to group results by.
sort_bystring (optional)Field to sort by.