Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Product Discovery Slots

Use Product Discovery slots to add content to a container or replace part of its UI. For example, you can change a filter label or add a star rating below a product name. Each slot receives a context object, ctx, with data and methods for changing its content. For methods shared by all slots, see Extending drop-in components.

The basic examples append a text label to show where each slot appears. They keep the default slot content. Replace the sample text with your own content. In each example, block is the element passed to your storefront block’s decorate function. Add the code to your existing provider.render() call rather than rendering the same container twice.

ContainerSlots
FacetsFacet, FacetHeading, SelectedFacets, Facets, FacetBucket, FacetBucketLabel
SearchResultsProductActions, ProductPrice, ProductName, ProductImage, NoResults, Header, Footer

The Facets container displays search filters, such as color and price. Use its slots to customize a filter group, an individual option, or the selected filters.

interface FacetsProps {
slots?: {
Facet?: SlotProps<{ data: SearchFacet }>;
FacetHeading?: SlotProps<{ data: SearchFacet }>;
SelectedFacets?: SlotProps<{ data: SearchFacet[] }>;
Facets?: SlotProps<{ data: SearchFacet[] }>;
FacetBucket?: SlotProps<{ data: FacetBucket }>;
FacetBucketLabel?: SlotProps<{ data: FacetBucket }>;
};
}

Use Facet to customize one filter group, including its heading and options. ctx.data contains the group’s SearchFacet data.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
Facet: (ctx) => {
// Keep the existing filter controls and append content after them.
const element = document.createElement('div');
element.innerText = 'Custom Facet';
ctx.appendChild(element);
}
}
})(block);

Use FacetHeading to customize each filter group’s heading. ctx.data contains the group’s SearchFacet data, including its title.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
FacetHeading: (ctx) => {
// Add content without replacing the default filter heading.
const element = document.createElement('div');
element.innerText = 'Custom FacetHeading';
ctx.appendChild(element);
}
}
})(block);

Use SelectedFacets to customize the selected filters section. ctx.data contains a SearchFacet[] array of groups with selected options.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
SelectedFacets: (ctx) => {
// Keep the selected-filter controls and append your own content.
const element = document.createElement('div');
element.innerText = 'Custom SelectedFacets';
ctx.appendChild(element);
}
}
})(block);

Use Facets to customize the full list of filter groups. Unlike Facet, which receives one group, this slot receives the complete SearchFacet[] array in ctx.data.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
Facets: (ctx) => {
// Append content after the list without replacing its filter groups.
const element = document.createElement('div');
element.innerText = 'Custom Facets';
ctx.appendChild(element);
}
}
})(block);

Use FacetBucket to customize one filter option, such as a color or price range. A bucket is an option within a filter group. ctx.data contains its FacetBucket data. This slot includes the option’s control and label.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
FacetBucket: (ctx) => {
// Add content while keeping the option's existing selection control.
const element = document.createElement('div');
element.innerText = 'Custom FacetBucket';
ctx.appendChild(element);
}
}
})(block);

Use FacetBucketLabel to customize an option’s label without replacing its selection control. ctx.data contains the option’s FacetBucket data.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { Facets } from '@dropins/storefront-product-discovery/containers/Facets.js';
await provider.render(Facets, {
slots: {
FacetBucketLabel: (ctx) => {
// Add content to the label without replacing the selection control.
const element = document.createElement('div');
element.innerText = 'Custom FacetBucketLabel';
ctx.appendChild(element);
}
}
})(block);

Use SearchResults slots to customize product cards, content above or below the results, and messages when no results are available.

The product card slots share SlotDefaultContext. Read the current product from ctx.product and the search parameters from ctx.variables. ProductImage also provides ctx.defaultImageProps with the default image settings. Header and Footer receive the full product array in ctx.products instead of a single product.

type SlotDefaultContext = {
product: Product;
variables: SearchVariables | null;
};
interface SearchResultsProps {
slots?: {
ProductActions?: SlotProps<SlotDefaultContext>;
ProductPrice?: SlotProps<SlotDefaultContext>;
ProductName?: SlotProps<SlotDefaultContext>;
ProductImage?: SlotProps<SlotDefaultContext & { defaultImageProps: ImageProps }>;
NoResults?: SlotProps<{ error: string | null; variables: SearchVariables | null }>;
Header?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;
Footer?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;
};
}

Use ProductActions to add actions to each product card. ctx.product contains the product for that card.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
ProductActions: (ctx) => {
// Add content to the card's actions area for the current product.
const element = document.createElement('div');
element.innerText = 'Custom ProductActions';
ctx.appendChild(element);
}
}
})(block);

Use ProductPrice to customize the price section of each product card. ctx.product contains the current product. The example keeps the default price and appends a text label.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
ProductPrice: (ctx) => {
// Keep the default price and append content after it.
const element = document.createElement('div');
element.innerText = 'Custom ProductPrice';
ctx.appendChild(element);
}
}
})(block);

Use ProductName to customize the name section of each product card. ctx.product contains the current product. Append content to keep the default name, as in the star rating example below.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
ProductName: (ctx) => {
// Keep the default product name and append content after it.
const element = document.createElement('div');
element.innerText = 'Custom ProductName';
ctx.appendChild(element);
}
}
})(block);

Use the ProductName slot to add an average star rating and approved review count below each product name. The following example renders the rating with the SDK StarRating component, with text such as 4.5 (12). This is a customization, not behavior included in the default product listing block.

The rating comes from two Catalog Service product attributes:

  • ac_rating_summary: The average rating on a scale from 0 to 100. Divide it by 20 to get a rating from 0 to 5 stars.
  • ac_review_count: The number of approved reviews.

Both attributes must be enabled for product listings. This setting is off by default. If cards show no ratings, follow Catalog attributes to enable it. For how review data reaches the catalog, see the Ratings and Reviews overview.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import SearchResults from '@dropins/storefront-product-discovery/containers/SearchResults.js';
import { StarRating, provider as UI } from '@dropins/tools/components.js';
// ac_rating_summary is a 0-100 percentage; products without ac_review_count get no rating.
const getReviewSummary = (product) => {
const getValue = (name) => product.attributes?.find((attr) => attr.name === name)?.value;
const reviewCount = Number.parseInt(getValue('ac_review_count'), 10);
if (!Number.isSafeInteger(reviewCount) || reviewCount < 0) return null;
// Converts the percentage to a 0-5 star value and keeps it in range.
const rating = Math.min(Math.max(Number(getValue('ac_rating_summary')) / 20 || 0, 0), 5);
const $rating = document.createElement('div');
$rating.className = 'product-discovery-product-rating';
// Renders, for example, five stars followed by "4.5 (12)".
UI.render(StarRating, {
rating,
reviewCount,
showCount: true,
valueDisplay: 'value',
countDisplay: 'parentheses',
})($rating);
return $rating;
};
await provider.render(SearchResults, {
slots: {
ProductName: (ctx) => {
const $rating = getReviewSummary(ctx.product);
// Keeps the default product name and adds the rating after it.
if ($rating) ctx.appendChild($rating);
},
},
})(block);

The example:

  • Reads the rating attributes from ctx.product.
  • Converts the average rating to a value from 0 to 5 and keeps it within that range.
  • Keeps the default product name and appends the rating after it.

Products without a valid ac_review_count show no rating. A product whose count is 0 shows the No reviews label instead of a numeric rating and count. To hide ratings for those products too, return null when reviewCount is less than 1.

Add these rules to blocks/product-list-page/product-list-page.css to size the stars for product cards:

blocks/product-list-page/product-list-page.css
/* Adds space between the product name and the rating. */
.block.product-list-page .product-discovery-product-rating {
margin-block-start: var(--spacing-xxsmall);
}
/* Uses smaller stars on product cards. */
.block.product-list-page .product-discovery-product-rating .dropin-star-rating__star svg {
height: 16px;
width: 16px;
}

The first rule adds space above the rating. The second sizes the star icons to 16 pixels.

Use ProductImage to customize each product card’s image. ctx.product contains the current product, and ctx.defaultImageProps contains the default image settings. The example keeps the default image and appends a text label.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
ProductImage: (ctx) => {
// Keep the default product image and append content after it.
const element = document.createElement('div');
element.innerText = 'Custom ProductImage';
ctx.appendChild(element);
}
}
})(block);

Use NoResults to customize the message area when a search has no results or fails. ctx.error contains the message, and ctx.variables contains the search parameters. Either value can be null. The example appends content without replacing the default message.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
NoResults: (ctx) => {
// Keep the default empty-results or error message.
const element = document.createElement('div');
element.innerText = 'Custom NoResults';
ctx.appendChild(element);
}
}
})(block);

Use Header to add content above the product results. ctx.products contains the result products, and ctx.variables contains the search parameters.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
Header: (ctx) => {
// Add content above the result products, not inside each card.
const element = document.createElement('div');
element.innerText = 'Custom Header';
ctx.appendChild(element);
}
}
})(block);

Use Footer to add content below the product results. Like Header, this slot receives the result products in ctx.products and the search parameters in ctx.variables.

blocks/product-list-page/product-list-page.js
import { render as provider } from '@dropins/storefront-product-discovery/render.js';
import { SearchResults } from '@dropins/storefront-product-discovery/containers/SearchResults.js';
await provider.render(SearchResults, {
slots: {
Footer: (ctx) => {
// Add content below the result products, not inside each card.
const element = document.createElement('div');
element.innerText = 'Custom Footer';
ctx.appendChild(element);
}
}
})(block);