Home > widget-integration > CartDrawerRecommendationService > fetchRecommendationProducts

CartDrawerRecommendationService.fetchRecommendationProducts() method

Fetch recommendation products from API via RecommendationService.

Override this method to: - Add custom filtering before/after fetch - Pass additional context (cart product IDs, customer ID) - Implement caching

Signature:

protected fetchRecommendationProducts(widgetId: string): Promise<RawRecommendationProduct[]>;

Parameters

Parameter

Type

Description

widgetId

string

The widget ID

Returns:

Promise<RawRecommendationProduct[]>

Promise resolving to raw products array

Example

Override to filter products or limit results per shop:

window.boostWidgetIntegration.extend('CartDrawerRecommendationService', (Base) => {
  return class extends Base {
    async fetchRecommendationProducts(widgetId) {
      const products = await super.fetchRecommendationProducts(widgetId);
      // Limit to 4 products and exclude out-of-stock
      return products
        .filter(p => p.available !== false)
        .slice(0, 4);
    }
  };
});