addSurfaces Method

Callable

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

    example
    editor.getProduct()
        // When we get the product.
        .then(function(product) {
            // Add an empty page and the "postcard" template to the beginning.
            product.addSurfaces(
                [{ width: 300, height: 300 }, { designFile: "postcard" }],
                0
            )
            // If there was an error while adding pages to the product.
            .catch(function (error) {
                console.error("Adding surfaces failed with exception: ", error);
            });
        });
    

    Parameters

    • surfaces: SurfaceTypes []

      An array of surfaces (pages) to add.

    • Optional position: number

      A position in the surface array where new surfaces should be added. The index of the first surface is 0. By default, this method adds pages to the end of the surface array.

    Returns Promise < Product >

    The product instance where the surfaces (pages) were added.