PrintAppClient class.
You can find a basic installation guide here.
This is how to initialize a PrintAppClient:
Parameters
Methods
Event types
Events are attached to thePrintAppClient after initialization using the addEventListener method.
The app:saved payload
Your listener receives an event whosedata describes the saved project:
Adding to the cart on save
With Add to Cart on Save turned on in a design’s settings, the client presses the store’s Add to Cart button for the customer after the project is saved. It waits for everyapp:saved listener to finish first, so the project can be attached to the cart line before the add.
A listener that does asynchronous work (posting the project to your server, say) must return its promise,
or the add can happen before that work is done:
printapp:addtocart event on document. Call preventDefault() and do the
add yourself:
Checking how far the editor got
The editor loads in steps: the client fetches your store settings, adds the editor’s frame to the page, the frame loads, the editor sends its first message to your page, the client sends it your parameters, the editor validates with our servers, and then it is ready. Whenapp:ready doesn’t arrive,
getBootStatus() tells you which step it stopped at:
When a step takes longer than 10 seconds,
stalled says which one, and the client logs a warning in the
console:
The other fields:
Loading the editor without a designId
This feature allows you to initilize the editor without having an prior design, by describing a design template. The parameter to pass unto the editor is an object titleddesignTemplate
A sample value is shown in the code below with detailed comments.