Home > widget-integration > CartDrawerRecommendationService > formatProductsForTemplate

CartDrawerRecommendationService.formatProductsForTemplate() method

Format products for template rendering.

Transforms raw API products into template-ready format with: - Formatted prices (using store currency settings) - Formatted variant prices - Consistent structure for Liquid template

Signature:

protected formatProductsForTemplate(products: RawRecommendationProduct[], showCurrencyCodes: boolean): FormattedProduct[];

Parameters

Parameter

Type

Description

products

RawRecommendationProduct[]

Raw products from API

showCurrencyCodes

boolean

Whether to show currency codes

Returns:

FormattedProduct[]

Formatted products array

Example

Override to add custom product properties for template rendering:

window.boostWidgetIntegration.extend('CartDrawerRecommendationService', (Base) => {
  return class extends Base {
    formatProductsForTemplate(products, showCurrencyCodes) {
      return super.formatProductsForTemplate(products, showCurrencyCodes)
        .map(product => ({
          ...product,
          customBadge: product.tags?.includes('new') ? 'New' : null,
        }));
    }
  };
});