Skip to main content

API Methods

Available methods

getProductAttributes

Get available attributes on a product. The client can then apply/change these attributes using setProductAttribute() method.

window.expivi.getProductAttributes().then(function(productAttributes){
console.log('available attributes: ', productAttributes);
});
Attribute Object Structure
PropertyDescriptionType
idAttribute’s ID to be used to set Attribute.number
nameAttribute's name.string
typeType of the attribute (e.g., question, matgroup, text_input, etc).string
slug(Optional) Attribute's slug.string
hash(Optional) Unique hash.string
descriptionDescription of the attribute.string
positionPosition of the attribute in the rendered list.number
thumbnailThumbnail file.string
thumbnail_urlComplete URL of the thumbnail.string
parent_idAttribute's parent ID [nullable].number
metaMetadata represented as meta.any
visibilityWhether the attribute is visible during initialization.number
globalIndicates if the attribute is global (used by more products).boolean
attribute_values(Optional) Available values, polymorphic based on type.AttributeValueInterface[]
entity_properties(Optional) Assigned entity properties on attribute.EntityPropertyInterface[]
selected_value_id(Optional) Currently selected attribute value ID (term).number
selected_value_value(Optional) Currently selected value.any
visible(Optional) Visibility changed by rules system.boolean

setProductAttribute

Set/change an attribute’s value on product.

window.expivi.setProductAttribute(aAttributeId : number, aValue : any);
Parameter Descriptions
ParameterDescriptionType
aAttributeIdThe ID of the attribute to change its value.number
aValueThe value to set for the attribute, based on its type.Depends on attribute's type
Possible Values for aValue Based on Attribute’s Type
Attribute TypeDescriptionExpected Value Type
questionAttribute value's ID.number
matgroupMaterial reference's ID.number
text_inputText to be set on input.string
text_to_imageText to be set.string
image_uploadURL of the uploaded image.string
color_pickerHex code of the selected color.string (hex code)
colorHex code of the selected color.string (hex code)

setProductAttributeNamed

Set/Change an attribute’s value on product.

window.expivi.setProductAttribute(aAttributeName : string, aValue : any);
Parameter Descriptions
ParameterDescriptionType
aAttributeNameThe name of the attribute to change its value.string
aValueThe value to set for the attribute, based on its type.Depends on attribute's type
note

The provided value (aValue) should correspond to the attribute’s type.
Refer to the setProductAttribute documentation for details on expected values based on the attribute type.

getActiveMaterial

Get the actively selected reference id of material inside a material group.

window.expivi.getActiveMaterial(aMaterialGroupId : number, aProductSceneId? : string) : Promise<number>;
Parameter Descriptions

Return a promise containing the active reference ID.

ParameterDescriptionType
aMaterialGroupIdThe ID of the material group.number
aProductSceneId(Optional) The unique product ID containing the material group (resolved from window.expivi.resolveProductNodes()).number

setActiveMaterial

Sets or selects the active material within a material group using its material reference ID.

window.expivi.setActiveMaterial(aMaterialGroupId : number, aReferenceId : number, aProductSceneId? : string) : Promise<number>;
Parameter Descriptions

Return a promise containing the selected reference ID.

ParameterDescriptionType
aMaterialGroupIdThe ID of a material group.number
aReferenceIdThe reference ID of the material inside the material group - see resolveMaterialGroupsnumber
aProductSceneId(Optional) The unique product ID containing the material group (resolved from window.expivi.resolveProductNodes()).string

getScreenshot

window.expivi.getScreenshot(aWidth : number, aHeight : number) : Promise<string>;
Parameter Descriptions

Return a promise containing a string with Base64 Image data.

ParameterDescriptionTypeDefault
aWidth(Optional) The width of the screenshot.number512
aHeight(Optional) The height of the screenshot.number512

getPrice

Calculate and return the total price of a product.

window.expivi.getPrice(aProductSceneId? : string) : Promise<number>;
Parameter Description

Return a promise containing a numeric value of the calculated price.

ParameterDescriptionTypeDefault
aProductSceneId(Optional) The unique product id to get its price (resolved from window.expivi.resolveProductNodes()).stringnull

setNodeProperty

Set/change an internal property of a scene object.

window.expivi.setNodeProperty(aNodeName : string, aProperty : {name : string, value : any}) : Promise<number>;
Parameter Descriptions

Return a promise containing the number of nodes affected.

ParameterDescriptionType
aNodeNameThe name of the scene object node to change its property.string
aPropertyAn object { name: string, value: any } containing the name of the property and the value to be set.{ name: string, value: any }

changeCameraZoom

Change the camera zoom by delta.

window.expivi.changeCameraZoom(aZoomDelta : number) : Promise<number>
Parameter Description
ParameterDescriptionType
aZoomDeltaThe delta, in negative or positive direction, to change the zoom with.number
note

The zoom will be capped by the minimum & maximum zoom defined in Expivi’s editor.

Return a promise containing the applied delta.

saveConfiguration

Save/Serialize the configured product - see Serialization.

window.expivi.saveConfiguration(aWidth : number, aHeight : number) : Promise<{
bundle_uuid : string,
configured_products: []
}>;
Parameter Descriptions
ParameterDescriptionTypeDefault Value
aWidth(Optional) The width of the screenshot.number512
aHeight(Optional) The height of the screenshot.number512

loadConfiguration

Load a previously configured product (serialized with saveConfiguration).

window.expivi.loadConfiguration(aConfiguration : {
bundle_uuid : string,
configured_products: []
}) : Promise<boolean>;
note

Reloading previous configurations can be done during initialization by providing the aConfiguredProduct attribute.

loadPreset

Load a preset configuration.

window.expivi.loadPreset(aProductSceneId : string | null, aPresetId : string) : Promise<boolean>;
note

You can apply preset only on an already created product of same catalogue id.

selectProductNode

Select active product node.

window.expivi.selectProductNode(aProductSceneId? : string) : Promise<ProductNode>;
Parameter Description
ParameterDescriptionTypeDefault Value
aProductSceneId(Optional) The unique product ID to select (resolved from window.expivi.resolveProductNodes()).stringmain product node
note

When having more than one configurable product inside the viewer, active product node can be changed to set/get its attributes without providing product id. Selecting a product node is also useful when movement of objects inside the scene is also activated, selecting products will activate their movement options in that case.

autoRotateYAxis

Rotate the product automatically on the Y axis.

window.expivi.autoRotateYAxis(aProductSceneId? : string, aStopOnInteraction = true, aSpeed = 1, aMaxDegree = 360) : Promise<ProductNode>;
Parameter Descriptions
ParameterDescriptionTypeDefault Value
aProductSceneId(Optional) The unique product ID to select (resolved from window.expivi.resolveProductNodes()).stringmain product node
aStopOnInteraction(Optional) Stop the automatic rotation when the user interacts with the viewer.booleantrue
aSpeed(Optional) The rotation speed of the animation.number1.0
aMaxDegree(Optional) The degree at which the animation will automatically stop.number360.0 or infinite: -1

deselect

Deselect any selected node inside the viewer.

window.expivi.deselect() : Promise<boolean>;

deleteNode

Delete a scene node from the viewer.

window.expivi.deleteNode(aSceneNodeId : string) : Promise<SceneNode>;
Parameter Description

Return a promise containing the deleted scene node (if any).

ParameterDescriptionType
aSceneNodeIdUnique scene node ID (in case of product node, resolved from window.expivi.resolveProductNodes()).string