Basket & Pricing

Generated reference for the iPrintessApi methods tagged #ai-api:basket-pricing in printess-editor.d.ts. Custom types referenced below (parameter and return shapes) are documented on the Types reference.

callPriceChangeCallback

callPriceChangeCallback(overWritePageCount?: number): void

Forces calling the shops price change callback Optionally can get a temporary page-count to send to the hosting page

Parameter Type Description
overWritePageCount? number

Returns: void

forceBasketButtonText

forceBasketButtonText(): boolean

Returns if UI should force the basket button to be in text form

Returns: boolean

getAllPriceRelevantFormFields

This method is deprecated.

getAllPriceRelevantFormFields(): { [key: string]: string }

Retrieves all price relevant form-field names and values

Returns: { [key: string]: string }

getAllPriceRelevantFormFieldsExt

getAllPriceRelevantFormFieldsExt(): {
    priceCategories: Array<string>,
    perLetterPriceCategories: Array<{ ffName: string, price: number, amount: number }>,
    formFields: {
      [key: string]: { value: string, tag: string, label: string }
    }
  }

Retrieves all price relevant form-fields plus tag information and referenced price-categories

Returns: { priceCategories: Array<string>, perLetterPriceCategories: Array<{ ffName: string, price: number, amount: number }>, formFields: { [key: string]: { value: string, tag: string, label: string } } }

getAnimationHtmlAsString

getAnimationHtmlAsString(docIdOrName?: string, spreadIndex?: number, pxWidth?: number): Promise<{ pxWidth: number, pxHeight: number, data: string } | null>

Returns the specified animation as a single html-string including all resources base64 encoded You just need to store the string in a .html file to use it.

Parameter Type Description
docIdOrName? string The document to render identified by id or name
spreadIndex? number The zero based spread index you want to render, defaults to 0 (first spread)
pxWidth? number The output width in pixel, defaults to the setup html-width of the animation. Max is 2000px, min is 100px

Returns: Promise<{ pxWidth: number, pxHeight: number, data: string } | null> — { pxWidth: number, pxHeight: number, data: string } “data” contains the HTML.

Used in these examples:

getBasketButtonBehaviour

getBasketButtonBehaviour(): "add-to-basket" | "go-to-preview" | "go-to-book-mook"

returns desired behaviour of basket button In steps-mode basket button always points to the basket. If no steps are present basket button should lead to the preview

Returns: “add-to-basket” | “go-to-preview” | “go-to-book-mook”

getBuyerFrameCountAndClasses

This method is deprecated.

getBuyerFrameCountAndClasses(): Array<iFrameCountAndMarkers>

Returns: Array<iFrameCountAndMarkers>

getBuyerFrameCountAndMarkers

getBuyerFrameCountAndMarkers(): Array<iFrameCountAndMarkers>

Returns an array of buyer-editable documents and a list of frames for each spread including their frame markers. You can easily use them for statistical purposes or to charge extra prices for certain used layouts. Or just use the frame-count to determine if the user had made changes at all.

Returns: Array<iFrameCountAndMarkers>

getFormFieldPriceLabelByTag

getFormFieldPriceLabelByTag(tag: string, propertyId?: string, newValue?: string): string

Get price labels for form-field badges from price-tags

Parameter Type Description
tag string price-tag to resolve the label for
propertyId? string optional to allow printess to check price-relevance of form field
newValue? string optional to calculate per letter price if applicable

Returns: string

getMaxmimumBasketHeight

getMaxmimumBasketHeight(): number

Gets the currently configured maximum basket image height.

Returns: number

getMaxmimumBasketWidth

getMaxmimumBasketWidth(): number

Gets the currently configured maximum basket image width.

Returns: number

getPriceRelevantData

getPriceRelevantData(): iExternalProductPriceInfo

returns all price relevant data of the current template

Returns: iExternalProductPriceInfo

getProductInfoUrl

getProductInfoUrl(): string

Get the link required for displaying an info icon that opens a product info overlay / dialog

Returns: string

getSamplePriceData

getSamplePriceData(): { priceTestModeEnabled: boolean, legalNotice: string, oldPrice: number, snippetPrices: Array<number>, priceCategories: { [key: string]: number }, basePrice: number, infoUrl: string, perPagePrice: number }

Provides access to the sample price data of the template. Only relevant for displaying test prices when priceTestModeEnabled is set.

Returns: { priceTestModeEnabled: boolean, legalNotice: string, oldPrice: number, snippetPrices: Array<number>, priceCategories: { [key: string]: number }, basePrice: number, infoUrl: string, perPagePrice: number }

noBasketThumbnail

noBasketThumbnail(): boolean

Returns true if the noBasketThumbnail flag was set on attach.

Returns: boolean

renderFirstPageImage

renderFirstPageImage(fileName: string, documentName?: string, maxWidth?: number, maxHeight?: number): Promise<string>

Renders the first page of a document as an image.

Parameter Type Description
fileName string deprecated. Not used anymore.
documentName? string Optional: The name of the document you want to render the pages images for. If not provided the one marked as thumbnail will be taken, otherwise the preview document, or as last try the first/primary document.
maxWidth? number Optional: Maximum render width. Defaults to 400.
maxHeight? number Optional: Maximum render height. Defaults to 400.

Returns: Promise<string> — Url to the image. Can be png with transparency or jpg.

renderPageImages

renderPageImages(fileNameSuffix: string, documentName?: string, maxWidth?: number, maxHeight?: number): Promise<string[]>

Renders all pages as images for the given document.

Parameter Type Description
fileNameSuffix string deprecated. Not used anymore.
documentName? string Optional: The name of the document you want to render the pages images for. If not provided the one marked as thumbnail will be taken, otherwise the preview document, or as last try the first/primary document.
maxWidth? number Optional: Maximum render width. Defaults to 400.
maxHeight? number Optional: Maximum render height. Defaults to 400.

Returns: Promise<string[]> — Array of urls to the images. They can be png with transparency or jpg.

renderProofPdfs

renderProofPdfs(): Promise<JobStatus>

Renders proof Pdf(s) in the shop scenario. You must allow this in the account portal first. Normally shop access forbids any kind of production.

Returns: Promise<JobStatus>

saveAndGenerateBasketThumbnailUrl

saveAndGenerateBasketThumbnailUrl(maxWidth?: number, maxHeight?: number): Promise<{ saveToken: string, basketUrl?: string }>

Saves current artwork and returns the saveToken and a basket thumbnail url. The thumbnail url creation could involve cost, as it is rendered server side. Makes the checkout process faster.

Parameter Type Description
maxWidth? number
maxHeight? number

Returns: Promise<{ saveToken: string, basketUrl?: string }>saveToken which you can pass on attachPrintess() or load(), plus the basketUrl of the server-rendered thumbnail if available

setPriceCategoryLabels

setPriceCategoryLabels(priceCategoryLabels: Record<string, string> | null): void

Reassign/change price category labels.

Parameter Type Description
priceCategoryLabels Record<string, string> | null

Returns: void

showAddToBasketButton

showAddToBasketButton(): boolean

Returns if UI should display a button to add current work into the basket

Returns: boolean

showProofButton

showProofButton(): boolean

Returns if UI should display a button to render a proof pdf of the current work in the buyer side

Returns: boolean