Home > widget-integration > CartService > getCartTemplate

CartService.getCartTemplate() method

Get cart template HTML for rendering Override to provide shop-specific templates or custom template loading logic

Template resolution priority: 1. TAEAppConfig.template.cart (from backend/metafield) - highest priority 2. Local static template file (fallback) - default

The template should use Liquid-compatible syntax and expect these variables: - items: Array of formatted cart items - item_count: Total number of items - items_subtotal_price: Formatted subtotal price - cartStyle: Cart display style ('side', 'modal', etc.) - locale: Current locale path - translations: Translation strings

Signature:

protected getCartTemplate(): Promise<string>;

Returns:

Promise<string>

Promise resolving to cart template HTML string

Example 1

Load template from custom location

protected async getCartTemplate(): Promise<string> {
  // Try shop-specific template first
  const shopId = this.appService.getConfig().shopId;
  const customTemplate = await this.loadCustomTemplate(shopId);

  if (customTemplate) {
    return customTemplate;
  }

  // Fallback to default
  return super.getCartTemplate();
}

Example 2

Template with custom structure

protected async getCartTemplate(): Promise<string> {
  const baseTemplate = await super.getCartTemplate();

  // Add custom sections to template
  const shopConfig = this.appService.getConfig();

  if (shopConfig.showRecommendations) {
    return this.injectRecommendationsSection(baseTemplate);
  }

  if (shopConfig.showLoyaltyPoints) {
    return this.injectLoyaltySection(baseTemplate);
  }

  return baseTemplate;
}