Product

A Customer's Canvas product.

Methods

Name Description
addSurface

Adds the given surface (page) to the product. Returns the product instance where the surface (page) was added.

removeSurface

Removes the given surface (page) from the product. Returns the product instance where the surface (page) was removed from.

setUserId

Set user unique identifier and move user files to the user folder. See the Working with User Data topic for details.

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

Unique identifier.

name

name: string

Item 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

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);
    });