Home > widget-integration > PredictiveBundleService

PredictiveBundleService class

Provides predictive bundle business logic, pricing calculations, and template access.

Most shop-specific customization should happen by extending this service instead of editing controller flows directly.

Signature:

export declare class PredictiveBundleService 

Example

window.boostWidgetIntegration.extend('PredictiveBundleService', (PredictiveBundleService) => {
  return class extends PredictiveBundleService {
    getWidgetSettings(widgetId) {
      const settings = super.getWidgetSettings(widgetId);
      return {
        ...settings,
        widgetDesignSettings: {
          ...settings.widgetDesignSettings,
          buttonText: 'Build my bundle',
        },
      };
    }
  };
});

Constructors

Constructor

Modifiers

Description

(constructor)(appService, platformLoader, templateAPI, predictiveBundleAPI, constants)

Constructs a new instance of the PredictiveBundleService class

Properties

Property

Modifiers

Type

Description

appService

protected

AppService

constants

protected

PredictiveBundleConstants

defaultSettings

readonly

Record<string, RecommendationWidget>

platformLoader

protected

PlatformLoader

predictiveBundleAPI

protected

PredictiveBundleAPI

templateAPI

protected

TemplateAPI

widgets

readonly

Record<string, RecommendationWidget>

Methods

Method

Modifiers

Description

buildCartPayload(products, options)

calculateBundleData(bundle, updateData, action)

Calculates derived bundle state such as selected variants, totals, and discount values.

Override this method to inject shop-specific bundle business rules while keeping the controller rendering flow unchanged.

calculateDiscountedPrice(products, discount, currencyRate)

calculateTotalPrice(products)

calculateTotalPriceWithDetails(products)

filterAvailableProducts(products)

filterCheckedProducts(products)

formatPrice(params)

Formats a monetary value using the current shop currency settings.

getBundleSessionData()

getLocale()

getPredictiveBundles(productId)

Proxies predictive bundle loading to the API layer.

getRawPrice(selectedOption)

getWidgetSettings(widgetId)

Merges widget-specific design settings with predictive bundle defaults.

getWidgetTemplate(templateName)

Loads the Liquid template used to render a bundle surface.

hasSelectedProducts(products)

isValidBundle(widgetId)

saveBundleSessionData(bundle)