Styling and Design

Choosing the amount of Facets to be shown on the Search Page

See how to limit the amount of facets to show

The Search page and Facets are fundamental for the conversion rate when your customers search.

However, in some cases you might need to change just how many facets are being shown, for example on mobile devices.

If you want to decrease the amount of facets to be shown, this customisation can be added to the Magento 2 extension.

In app/design/frontend/Custom/Theme/Clerk_Clerk/templates/result.phtml add the function below:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
/* check ^^ for mobile only */
var facetOptions = $('#clerk-search-filters .clerk-facets dd');
facetOptions.each(function(i, el)
{
if (i < 4) {
return;
}
else if (i == 4) {
$(el).addClass('fade');
}
else if (i > 4) {
$(el).addClass('hidden');
}
else if (i < 11) {
return false;
}
});


That will give you the chance to decide how many facets per attribute to show before displaying the "Show more" button.

If you want to show more than 4 facets, simply change 4 everywhere in the function to a different number.