Interface: WorkflowExperience
A Workflow experience encapsulates the workflow manager and command context. It provides a simplified interface for interacting with the workflow manager. You should get an instance of this class from a Client you have constructed previously.
Methods
addEventListener()
addEventListener(
type,callback):void
Registers a callback function to be called when the specified event is raised. TODO: We should include a second param to pass information about the event?
Parameters
type
The type of event to listen for.
callback
(workflowExperience) => void
The function to call when the event occurs.
Returns
void
assignCustomerDetails()
assignCustomerDetails(
details):Promise<void>
Attach specific details about the customer to the experience. This is useful for things like retargeting. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.
Parameters
details
The new customer details.
Returns
Promise<void>
attachAddress()
attachAddress(
streetAddress?,apartment?,city?,country?,state?,postCode?):Promise<void>
Parameters
streetAddress?
string
apartment?
string
city?
string
country?
string
state?
string
postCode?
string
Returns
Promise<void>
attachCustomerDetails()
attachCustomerDetails(
details):Promise<void>
Attach specific details about the customer to the experience. This is useful for things like retargeting. Currently only email is supported. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.
Parameters
details
The new customer details. Only email is supported.
email
string
An email used for things like sending a design to the user.
Returns
Promise<void>
Deprecated
Use assignCustomerDetails instead.
attachOrganization()
attachOrganization(
name):Promise<void>
Parameters
name
string
Returns
Promise<void>
attachRenderableSceneListener()
attachRenderableSceneListener(
cb):void
Attaches a listener to the scenes on a workflow experience. The scenes returned are a subset of the scenes configured in the workflow and are based on the current state of the experience. This is useful for building a navigation menu.
Parameters
cb
(scenes) => void
The callback to be called when the scenes change. The new scenes are passed as an argument.
Returns
void
callEvent()
callEvent(
type):any
Parameters
type
Returns
any
checkForPriceBreakChanges()
checkForPriceBreakChanges():
void
Calculates the price break and fires the "PriceBreakChanged" event if required. This function is primarily intended for internal use.
Returns
void
clearProduct()
clearProduct():
Promise<void>
Clear the product from this experience.
Returns
Promise<void>
copy()
copy():
Promise<WorkflowExperience>
Returns a copy of the currently loaded design as a new, seperated workflow experience with a fresh transaction.
Returns
Promise<WorkflowExperience>
copySelectionsViaGlobalConfiguration()
copySelectionsViaGlobalConfiguration(
bundle,experience,filter?):Promise<void>
Takes selections made by the user in another workflow and applies them to this workflow. For selections to be copied they must both have a matching global property configuration.
Parameters
bundle
experience
WorkflowExperience
The experience to take selections from.
filter?
A list of steps to apply the selections to. If undefined all steps will be updated.
Returns
Promise<void>
createPreviewImage()
createPreviewImage(
isThreeD?,resolution?):Promise<string>
Creates a data URL preview for the current design.
Parameters
isThreeD?
boolean
resolution?
number
Returns
Promise<string>
detachRenderableSceneListener()
detachRenderableSceneListener(
cb):void
Detaches a listener from the scenes on a workflow experience.
Parameters
cb
(scenes) => void
Returns
void
getAdditionalProductPriceSubunits()
getAdditionalProductPriceSubunits(
disablePriceBreaks?):number|undefined
If an additional product is configured, returns the base price of that product. Returns undefined otherwise.
Parameters
disablePriceBreaks?
boolean
Whether to exclude price breaks from the calculation.
Returns
number | undefined
getBasePriceSubunits()
getBasePriceSubunits(
includeAdditionalProduct?,disablePriceBreaks?):number
Returns the total cost in subunits for the base product.
Parameters
includeAdditionalProduct?
boolean
When true the additional product cost will be included in the total (if configured).
disablePriceBreaks?
boolean
Whether to exclude price breaks from the calculation.
Returns
number
getBundle()
getBundle():
Bundle|undefined
Get the bundle this experience is part of. May be undefined.
Returns
Bundle | undefined
getClient()
getClient():
SpiffCommerceClient
Returns the client that was responsible for spawning this experience.
Returns
getCommandContext()
getCommandContext():
CommandContext
State related to the design of the user.
Returns
getExportedStepData()
getExportedStepData():
Promise<ExportedStepData[]>
Returns the metadata associated with this workflow experience. This is a combination of the metadata from the workflow, and the selections made by the user.
Returns
Promise<ExportedStepData[]>
An array of ExportedStepData objects, each containing the step ID, title, and properties.
getIsReadOnly()
getIsReadOnly():
boolean
Returns true when the user may only view the design.
Returns
boolean
getProduct()
getProduct():
Product|undefined
Get the current product for this experience. May be undefined.
Returns
Product | undefined
getProfanityList()
getProfanityList():
string[]
Get the current profanity list for this experience. May be empty.
Returns
string[]
getQuantity()
getQuantity():
number
Get the quantity of this WorkflowExperience's Transaction.
Returns
number
The amount that was, or will be, ordered.
getScenes()
getScenes():
Scene[]
Returns a list of scenes that are configured in the workflow. Each scene contains a list of steps. See getStepsByScene to access these.
Returns
Scene[]
getSelectionPriceSubunits()
getSelectionPriceSubunits(
disablePriceBreaks?):number
Returns the total cost in subunits for all selections made on the design.
Parameters
disablePriceBreaks?
boolean
Whether to exclude price breaks from the calculation.
Returns
number
getSilentStepFailures()
getSilentStepFailures():
SilentStepRedrawError|undefined
The silent steps (Product Overlay, Silent Illustration) which could not be drawn by the most recent background
draw, or undefined if everything was drawn. The draw starts after each updateWorkflowConfiguration resolves,
so this can briefly show the previous result. Failed steps are retried by every later update, and this is
cleared as soon as a draw succeeds for them all. Listen for WorkflowExperienceEventType.SilentStepsFailed to
be told when this changes to a failure.
Returns
SilentStepRedrawError | undefined
getStepById()
getStepById(
id):StepHandle<AnyStepData> |undefined
Returns the step matching a given name, undefined if not found.
Parameters
id
string
The id the step must match.
Returns
StepHandle<AnyStepData> | undefined
getStepByName()
getStepByName(
name):StepHandle<AnyStepData> |undefined
Returns the step matching a given name, undefined if not found.
Parameters
name
string
The name the step must match.
Returns
StepHandle<AnyStepData> | undefined
getSteps()
getSteps():
StepHandle<AnyStepData>[]
Returns all steps in the workflow. Ordered by scene and appearance within their respective scenes.
Returns
getStepsByScene()
getStepsByScene(
scene):StepHandle<AnyStepData>[]
Returns all steps that are children of a given scene.
Parameters
scene
Scene
The scene you want the steps for.
Returns
getStepsByType()
getStepsByType(
type):StepHandle<AnyStepData>[]
Returns all steps matching a specific type in the workflow. These steps may be across multiple scenes and may or may not be active based on condition state.
Parameters
type
Returns
getStepsConditionallyActive()
getStepsConditionallyActive():
Promise<StepHandle<AnyStepData>[]>
Returns all steps in the workflow that are conditionally active. Ordered by scene and appearance within their respective scenes.
Returns
Promise<StepHandle<AnyStepData>[]>
getTotalPriceSubunits()
getTotalPriceSubunits(
disablePriceBreaks?):number
A convenience function returning the sum of the selection and base price values.
Parameters
disablePriceBreaks?
boolean
Whether to exclude price breaks from the calculation.
Returns
number
getTransaction()
getTransaction():
Transaction
Get the current transaction for this experience.
Returns
getWorkflow()
getWorkflow():
Workflow|undefined
Get the current workflow for this experience. May be undefined.
Returns
Workflow | undefined
getWorkflowManager()
getWorkflowManager():
WorkflowManager
Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.
Returns
onDesignFinished()
onDesignFinished(
capturePreviewImage?):Promise<DesignCreationMessage>
To be called when the workflow experience is considered completed by the user.
Parameters
capturePreviewImage?
boolean
When true a preview image will be generated for the design. Defaults to true.
Returns
Promise<DesignCreationMessage>
priceBreakToBeApplied()
priceBreakToBeApplied():
number
The price break percentage that is expected to be applied in price calculations.
Returns
number
removeEventListener()
removeEventListener(
type,callback):void
Removes a previously registered callback.
Parameters
type
The type of event.
callback
(workflowExperience) => void
The function to remove.
Returns
void
save()
save(
title):Promise<SavedDesign>
Saves this experience to storage. This may be local or remote depending on configuration.
Parameters
title
string
The title for the saved design.
Returns
Promise<SavedDesign>
setBundle()
setBundle(
bundle):any
Set the bundle this experience is part of. Can be cleared using undefined.
Parameters
bundle
Bundle | undefined
Returns
any
setProduct()
setProduct(
integrationProductId):Promise<void>
Set the current product for this experience.
Parameters
integrationProductId
string
Returns
Promise<void>
setQuantity()
setQuantity(
quantity):Promise<void>
Sets the quantity of this WorkflowExperience's Transaction.
Parameters
quantity
number
The amount that was, or will be, ordered.
Returns
Promise<void>
A promise that resolves when the Transaction has been updated on the server.
Throws
if the WorkflowExperience is read-only.
Throws
if the value is below 1.
setWorkflow()
setWorkflow(
workflow):Promise<void>
Set the current workflow for this experience.
Parameters
workflow
The new workflow to set.
Returns
Promise<void>
updateWorkflowConfiguration()
updateWorkflowConfiguration(
changes):Promise<void>
Updates the workflow configuration dynamically and regenerates affected structures. This allows for runtime changes to scenes, steps, panels, and their configurations.
Resolves as soon as the configuration has changed and the preview is updated. Silent steps (Product Overlay,
Silent Illustration) are drawn afterwards in the background and appear when ready, so a slow image never holds
up the update. Use WorkflowExperienceEventType.SilentStepsFailed to be told if any could not be drawn.
Parameters
changes
Workflow update request specifying which items were added, changed, or removed
Returns
Promise<void>