Skip to main content
Skip table of contents

Controller methods

load

Loads product information and begins customization process.

  • options Optional parameter overrides, for example a new product list.

  • Returns void

destroy

Destroys the controller instance and frees the resources.

  • Returns void

products

Gets a list of currently loaded products.

  • Returns [string]

findProduct

Searches currently loaded blueprint for a product in the list of related products.

  • styleCode The product id to find.

  • Returns Object

isAvailable

Checks if component is available, i.e. it is not disabled in the Customize backend, and has sufficient inventory levels.

  • component Component

  • Returns boolean

getPrice

Calculates the price of the given component code.

  • component Component to calculate the price for

  • Returns number

statePrice

Calculates the overall state price, including the range of possible prices if different component selections were made.

  • options.excludePlacements A list of placement codes to be excluded from the price calculation.

  • options.fixedPlacements A list of placement codes that should reflect the current component selection price rather than respective min/max component prices.

  • options.ignoreOptional Ignores price of optional components when calculating min/max prices.

  • options.ignorePlaceholders Ignores price of placeholder components when calculating min/max prices.

  • Returns Object Returns an object with the current, minimal, and maximum prices based on currently selected state.

canBuild

Checks whether current state can be built, for example if placeholders have been replaced with actual options.

  • options.ignoreOptional Allows optional placeholders to remain unfulfilled.

  • options.excludePlacements A list of placements to ignore when considering whether the design can be built.

  • Returns boolean

transferCompatibleState

Transfer a compatible state selections from another to this controller, optionally bringing over only the specified placements. A state selection is considered to be compatible is it matches a placement code and a component can be selected in that placement.

  • controller Source controller

  • Returns void

isSelected

Checks if a code is selected in the current state.

  • componentCode Component code to check

  • Returns boolean

acceptableComponents

Finds a list of components acceptable in the placement.

  • placementCode Target placement code

  • Returns Array Returns a list of placement + component objects supported in the placement.

findComponent

Finds a component object by the given component code.

  • code Component code

  • Returns Object

findPlacement

Finds a placement object by the given placement code.

  • code Placement code

  • Returns Object

searchComponents

Find components in the placement that match given options.

  • placementCode Placement code.

  • searchOptions.code Component option code to search for.

  • searchOptions.definition Option definition code to search for.

  • Returns Array

updateComponent

If the selection is can be made, updates the selected component for the given placement.

  • placementCode Target placement code

  • componentCode Component to be selected

  • Returns Object Returns a previously selected component or {} if there was no component selected for the placement.

updateSimilarComponent

A method that is similar to updateComponent, however it allow to search from a new component based on the current selection and a new option code. For example, a text personalization is typically comprised from a font and a color. Using this method allows to easily update one or another without affecting the text entry or the other selected option. If the selection is can be made, updates the selected component for the given placement.

  • placementCode Target placement code

  • componentDefinitionName Component option definition name to search

  • componentOptionCode New option code to select

  • Returns Object Returns a previously selected component or {} if there was no component selected for the placement.

updateDynamicImage

Updates dynamic image reference associated with the placement.

  • placementCode The placement to be updated.

  • options.title The image title.

  • options.title The original image file name.

  • options.url The source image URL in the original image format.

  • options.pngUrl The URL of the PNG version of the dynamic image.

  • options.jpgUrl The URL of the PNG version of the dynamic image.

  • Returns Promise(Object)

commitCustomAttributes

Commits custom attribute changes to a component currently selected in the placement. Modifies .custom attributes map for the component, performs necessary validations, and updates image views as necessary.

  • placementCode The placement code. Selected component must have custom attributes to begin with.

  • changes The dictionary of custom attributes values changes to be applied to the component

  • Returns Promise(boolean) Returns a promise that resolves into an object specifying whether any changes were actually committed.

updatePersonalization

Updates the personalization text for a placement.

  • placementCode The Placement to be updated.

  • text The new personalization text.

  • updateOptions.noEnforceLimit Don't enforce personalization-limit when accepting new text.

  • Returns Promise(Object) Returns a promise that resolves to an object:

    • { accepted: true } if personalization is accepted as-is

    • { accepted: true, as: 'filtered text'} if personalization is accepted in filtered form.

    • { accepted: false, lastValid: 'last valid text' } if personalization text is rejected due to configured restrictions.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.