Specifying Product Tags

You may want to tag your products with related details. Customer's Canvas supports two types of these details. First, you can provide them as PDF metadata in the hi-res output. Also, you can add tags as keywords to your product that can improve the product design process in the web-to-print editor.

PDF metadata

Customer's Canvas allows you to save five properties in PDF hi-res outputs:

  • Author
  • Creator
  • Keywords
  • Subject
  • Title

You can both predefine these properties prior to loading the editor and specify them at runtime.

To predefine metadata, set up the hiResOutputPdfMetadata object for rendering through either the ~\Configuration\clientConfig.json file or the IPdfMetadata interface:

JavaScript
// Initialize the editor with the "Postcard.psd" template.
productDefinition = {
    surfaces: ["Postcard"]
};

// Set up PDF metadata.
configuration = {
    rendering: {
        hiResOutputPdfMetadata: {
            title: "The red postcard",
            keywords: "red,flower,postcard"
        }
    }
};

CustomersCanvas.IframeApi.loadEditor(iframe, productDefinition, configuration);

The setPdfMetadata and getPdfMetadata methods allow working with PDF metadata at runtime.

Tags

To pass attributes, which you may need at the moment of processing the ordered product, you can use tags. Customer's Canvas allows you to specify them through Product.setTags. To read these tags, use the Product.getTags method. The following example shows how you can set product tags.

JavaScript
// The product is a postcard with a flower image in red colors.
var newTags = ["red", "flower", "postcard"];

editor.getProduct()
    .then(function (product) {
        product.setTags(newTags)
        .catch(function (error) {
            console.error("Setting tags failed with exception: ", error);
        });
    });

Here, you classify the product by the palette, image, and type.

Let us look at how you can set up mockups based on product tags at runtime. In the following example, we set up a foreground mockup for photos and a background mockup for cups.

JavaScript
var frameMockup = {
    up: {
        // Set up the foreground mockup "photoFrame.psd".
        mockupFile: "photoFrame"
    }
}

var cupMockup = {
    down: {
        // Set up the background mockup "paperCup.psd".
        mockupFile: "paperCup"
    }
}

editor.getProduct()
    .then(function (product) {
        product.getTags()
        .then(function (tags) {
            if (tags != null) {
                // Set up the background mockup for cups.
                if (tags.indexOf("cup") != -1) {
                    product.currentSurface.setMockup(cupMockup);
                }
                // Set up the foreground mockup for photos.
                if (tags.indexOf("photo") != -1) {
                    product.currentSurface.setMockup(frameMockup);
                }
            }
        })
        .catch(function (error) {
            console.error("Getting tags failed with exception: ", error);
        });
    });

See Also

Manual

IFrame API Reference