Skip to main content

Class: CollectionProduct

A collection product is a product within a ProductCollection. It provides a simple interface for interacting with the product.

Constructors​

Constructor​

new CollectionProduct(productCollectionProduct): CollectionProduct

Parameters​

productCollectionProduct​

ProductCollectionProductResource

Returns​

CollectionProduct

Methods​

getAllWorkflows()​

getAllWorkflows(): ProductWorkflow[]

Returns​

ProductWorkflow[]

All workflows associated with this Product.


getBasePrice()​

getBasePrice(includeAdditionalProduct?): number

Gets the base price of the product. Optionally include additional product pricing.

Parameters​

includeAdditionalProduct?​

Optionally include additional product pricing. You must provide at least one of the fields on this object.

externalId?​

string

The external ID of the integration to locate the additional product on.

integrationId?​

string

The internal Spiff integration ID to locate the additional product on.

integrationType?​

IntegrationType

The integration type to locate the additional product on.

Returns​

number


getCurrentIntegration()​

getCurrentIntegration(): IntegrationProductResource

Returns​

IntegrationProductResource


getDefaultWorkflow()​

getDefaultWorkflow(): ProductWorkflow

A helper function for pulling the default workflow.

Returns​

ProductWorkflow


getDisplayImage()​

getDisplayImage(): string | undefined

Returns​

string | undefined

A url to the product's display image, if one exists.


getId()​

getId(): string

The ID of the product in SpiffCommerce.

Returns​

string


getIntegrationByType()​

getIntegrationByType(type, externalId?): IntegrationProductResource

A helper function for getting integrations

Parameters​

type​

IntegrationType

The type of integration you want.

externalId?​

string

An external integration ID to further filter by. Otherwise we return the first encountered.

Returns​

IntegrationProductResource

The integration if found. Throws an error if not found as this data is typically a neccesity.


getIntegrations()​

getIntegrations(): IntegrationProductResource[]

A list of all integrations this product is connected to.

Returns​

IntegrationProductResource[]


getName()​

getName(): string

The name of the product. Human readable.

Returns​

string


getResource()​

getResource(): Product

The raw product resource. This is generally not needed and should be avoided.

Returns​

Product


requestMetafields()​

requestMetafields(keys): Promise<Map<string, string>>

Requests a set of metafields for this product. Metafields that are not available locally will be fetched from the server.

Parameters​

keys​

string[]

The set of metafield keys to request.

Returns​

Promise<Map<string, string>>

A map of metafield key to value. Any unavailable keys will not be present in the map. use map.has() to check if a key is present.