getProduct

Callable

  • getProduct( ) : Promise < Product >
  • Returns the product currently loaded in the editor.

    example
    // Let us add the back side to a postcard.
    editor.getProduct()
        // When we get the product.
        .then(function(product) {
            // If postcard has no back side.
            if (product.surfaces.length < 2) {
                   // Adding the back to the loaded product.
                return product.addSurface(
                    { 
                        // Defining template file.
                        printAreas: [{ designFile: "postcard_side2"}]
                    })
                    // If the back side is added to the postcard.
                    .then(function(newProduct) {
                        // Replace the loaded product with the new one.
                        product = newProduct;
                    });
            }
        })
        // If there was an error while getting product or adding the back side to the postcard.
        .catch(function (error) {
            console.error("Adding surface failed with exception: ", error);
        });
    

    Returns Promise < Product >