Home > widget-integration > RecommendationAPI > buildRecommendationQueryParams

RecommendationAPI.buildRecommendationQueryParams() method

Builds and enhances query parameters for recommendation API requests.

This method transforms the base query parameters through a functional pipeline that automatically adds currency information and B2B-specific parameters. It serves as a key extension point for Technical Support teams to inject shop-specific query parameters without modifying the core request flow.

The method uses functional composition (pipe) to apply transformations sequentially, ensuring each enhancement step is clearly separated and maintainable.

Signature:

protected buildRecommendationQueryParams(params: RecommendationQueryParams): RecommendationQueryParams;

Parameters

Parameter

Type

Description

params

RecommendationQueryParams

Base recommendation query parameters including pagination settings, filters, and widget configuration. These are typically provided by the widget implementation or recommendation controller.

Returns:

RecommendationQueryParams

Enhanced query parameters with currency settings, B2B configurations, and any custom shop-specific parameters added through overrides. The returned object contains all parameters ready for API request serialization.

Remarks

The default implementation applies transformations in this order: 1. **Currency parameters**: Adds current currency code and conversion settings via 2. **B2B parameters**: Adds customer group, pricing tier, and B2B-specific settings via

This method is designed for extension - override it to add additional parameters while preserving the default currency and B2B transformations by calling the parent implementation.

Performance note: The functional pipe approach has minimal overhead and allows for efficient parameter transformation without unnecessary object copying.

Example 1

Override to add custom pricing tier for wholesale customers:

protected buildRecommendationQueryParams(params: RecommendationQueryParams): RecommendationQueryParams {
  // Apply default transformations first
  const enhanced = super.buildRecommendationQueryParams(params);

  // Add wholesale pricing parameters
  const customer = this.platformLoader.platform.customer;
  if (customer?.tags?.includes('wholesale')) {
    enhanced.pricing_tier = 'wholesale';
    enhanced.discount_level = 'tier-1';
  }

  return enhanced;
}

Example 2

Override to add customer segment and personalization flags:

protected buildRecommendationQueryParams(params: RecommendationQueryParams): RecommendationQueryParams {
  const enhanced = super.buildRecommendationQueryParams(params);

  // Add customer segment for personalized recommendations
  const customer = this.platformLoader.platform.customer;
  if (customer) {
    enhanced.customer_segment = customer.ordersCount > 5 ? 'loyal' : 'new';
    enhanced.personalization_enabled = true;
  }

  // Add A/B test variant
  enhanced.ab_test_variant = this.getABTestVariant();

  return enhanced;
}

Example 3

Override to add location-based filtering:

protected buildRecommendationQueryParams(params: RecommendationQueryParams): RecommendationQueryParams {
  const enhanced = super.buildRecommendationQueryParams(params);

  // Add shipping zone for location-specific recommendations
  const shippingZone = this.getCustomerShippingZone();
  if (shippingZone) {
    enhanced.shipping_zone = shippingZone;
    enhanced.regional_products_only = true;
  }

  return enhanced;
}