addSurface Method

Callable

// Let us add a back side to the 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 the 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 the product or adding a back side to the postcard.
.catch(function (error) {
console.error("Adding surface failed with exception: ", error);
});