Controller methods
load
Loads product information and begins customization process.
optionsOptional 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.
styleCodeThe 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.
componentComponentReturns
boolean
getPrice
Calculates the price of the given component code.
componentComponent to calculate the price forReturns
number
statePrice
Calculates the overall state price, including the range of possible prices if different component selections were made.
options.excludePlacementsA list of placement codes to be excluded from the price calculation.options.fixedPlacementsA list of placement codes that should reflect the current component selection price rather than respective min/max component prices.options.ignoreOptionalIgnores price of optional components when calculating min/max prices.options.ignorePlaceholdersIgnores price of placeholder components when calculating min/max prices.Returns
ObjectReturns 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.ignoreOptionalAllows optional placeholders to remain unfulfilled.options.excludePlacementsA 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.
controllerSource controllerReturns
void
isSelected
Checks if a code is selected in the current state.
componentCodeComponent code to checkReturns
boolean
acceptableComponents
Finds a list of components acceptable in the placement.
placementCodeTarget placement codeReturns
ArrayReturns a list of placement + component objects supported in the placement.
findComponent
Finds a component object by the given component code.
codeComponent codeReturns
Object
findPlacement
Finds a placement object by the given placement code.
codePlacement codeReturns
Object
searchComponents
Find components in the placement that match given options.
placementCodePlacement code.searchOptions.codeComponent option code to search for.searchOptions.definitionOption definition code to search for.Returns
Array
updateComponent
If the selection is can be made, updates the selected component for the given placement.
placementCodeTarget placement codecomponentCodeComponent to be selectedReturns
ObjectReturns 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.
placementCodeTarget placement codecomponentDefinitionNameComponent option definition name to searchcomponentOptionCodeNew option code to selectReturns
ObjectReturns a previously selected component or {} if there was no component selected for the placement.
updateDynamicImage
Updates dynamic image reference associated with the placement.
placementCodeThe placement to be updated.options.titleThe image title.options.titleThe original image file name.options.urlThe source image URL in the original image format.options.pngUrlThe URL of the PNG version of the dynamic image.options.jpgUrlThe 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.
placementCodeThe placement code. Selected component must have custom attributes to begin with.changesThe dictionary of custom attributes values changes to be applied to the componentReturns
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.
placementCodeThe Placement to be updated.textThe new personalization text.updateOptions.noEnforceLimitDon'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.