Skip to main content

Bundle

A bundle serves as a container for a set of workflow experiences. See Bundles for more information.

Functions

addStakeholder(customerDetails: CustomerDetailsInput, stakeholderType?: StakeholderType): Promise<void>

Adds a stakeholder to the bundle. See Customer Details for more information.

customerDetails: CustomerDetailsInput

The details of the stakeholder, such as email address, first name, last name, and phone number.

stakeholderType?: StakeholderType

The type of stakeholder to add. This defaults to "Owner".

addWorkflowExperience(): Promise<void>

Adds a workflow experience to the bundle. See Adding & Removing Workflow Experiences for more information.

getAllStakeholders(): Promise<BundleStakeholder[]>

Returns a promise that resolves to all of the stakeholders that are associated with this bundle. See Customer Details for more information.

getClient(): SpiffCommerceClient

Returns the SpiffCommerceClient that this bundle was created with.

getId(): string

Returns the ID of the bundle.

getGlobalProperties(): Promise<GlobalPropertyHandle[]>

Returns a promise that resolves to an array of GlobalPropertyHandle objects. These objects contain information about the global properties that are available to the bundle, and can be used to set their values. See Global Properties for more information.

getGlobalPropertyStateManager(): GlobalPropertyStateManager

Returns the GlobalPropertyStateManager for the bundle. It is not recommended to interact with this directly, instead use the getGlobalProperties function.

getMetadata(): Map<string, string>

Returns a map of arbitrary metadata that was set on the bundle.

getName(): string

Returns the name of the bundle, or an empty string if the bundle has not been named.

getProductCollection(): ProductCollection | undefined

Returns the ProductCollection object that is associated with this bundle, or undefined if the bundle does not have a product collection.

getTotalSubunits(): number

Returns the total number of subunits in the bundle. This is the sum of the total for all individual transactions in the bundle.

getWorkflowExperienceCount(): number

Returns the number of workflow experiences that are in the bundle.

getWorkflowExperiences(): WorkflowExperience[]

Returns an array of WorkflowExperience objects that are in the bundle.

hasGlobalProperties(): boolean

Returns true if the bundle has global properties, otherwise false.

removeWorkflowExperience(): Promise<void>

Removes a workflow experience from the bundle. See Adding & Removing Workflow Experiences for more information.

setMetadata(metadata: Map<string, string>): Promise<void>

Sets the metadata of the bundle and returns a promise that will resolve when it has been updated on the server. This will replace any existing metadata.

setName(name: string): Promise<void>

Sets the name of the bundle and returns a promise that will resolve when the name has been updated on the server.

name: string

The new name of the bundle.

setNameAndMetadata(name: string, metadata: Map<string, string>): Promise<void>

Sets the name and metadata of the bundle and returns a promise that will resolve when they have been updated on the server.

name: string

The new name of the bundle.

metadata: Map<string, string>

A map of arbitrary metadata to set on the bundle. This will replace any existing metadata.

sortWorkflowExperiences(sortFunc: (a: WorkflowExperience, b: WorkflowExperience) => number): Promise<void>

Sorts the workflow experiences in the bundle using the provided sort function.

The sorting is performed immediately and the promise will resolve when the ordering changes have been updated on the server.

sortFunc: (a: WorkflowExperience, b: WorkflowExperience) => number

A function that compares two workflow experiences and returns a number. See Array.prototype.sort for more information.

updateStakeholders(stakeholders: BundleStakeholderInput[]): Promise<void>

Updates the stakeholders of the bundle and returns a promise that will resolve when they have been updated on the server. See Customer Details for more information.

stakeholders: BundleStakeholderInput[]

An array of BundleStakeholderInput objects that represent the stakeholders to update. Any items that are not included in this array will be removed from the bundle, and any items not present on the server will be added to the bundle.