Product Class

A Customer's Canvas product.

Methods

Name Description
addSurface

Adds the given surface (page) to the product.

addSurfaces

Adds a number of surfaces (pages) to the product.

applyProductTheme

Applies a color theme to the product.

getTags

Reads product tags.

removeSurface

Removes the given surface (page) from the product.

setMockups

Sets mockups for several product pages.

setSurfaces

Replaces a product.

setTags

Specifies tags for the product.

setUserId

Sets the user unique identifier and move user files to the user folder. For details, see the Working with User Data topic.

swapSurfaces

Swaps two surfaces (pages) in the product. Returns the product instance where the surfaces (pages) were swapped.

switchTo

Opens the given product surface in the designer. Returns the product with the given surface (page) opened.

Properties

currentSurface

currentSurface: Surface

A surface (page) currently opened in the editor.

example
editor.getProduct()
    .then(function (product) {
        // Remove the current surface.
        product.removeSurface(product.currentSurface)
            .then(function(result) {
                console.log("Surface removed");
            });
    })
    // If there was an error thrown while removing the surface.
    .catch(function (error) {
        console.error("Removing the surface failed with exception: ", error);
    });

id

id: string

A unique product identifier.

name

name: string

A product name.

surfaces

surfaces: Surface []

Product surfaces (pages).

example
editor.getProduct()
    .then(function (product) {
        // Get the current surface index.
        const indexOfCurrentSurface = product.surfaces.lastIndexOf(product.currentSurface);
        if (indexOfCurrentSurface < 0)
            throw "Surface not found!";

        let indexOfNextSurface = indexOfCurrentSurface + 1;
        if (indexOfNextSurface > (product.surfaces.length - 1))
            indexOfNextSurface = 0;

        // Switch to the next surface.
        return product.switchTo(product.surfaces[indexOfNextSurface]);
    })
    .then(function(result) {
        console.log("Surface switched");
    })
    .catch(function (error) {
        console.error("Switching the surfaces failed with exception: ", error);
    });

userId

userId: string

A user identifier.

example
editor.getProduct()
    .then(function (product) {
        // Name your product.
        product.name = "Summer photos";
        console.log("Current user: " + product.userId + ", product name: " + product.name + ", product id: " + product.id);
    });