LogoLogo
  • iPaper Technical Documentation
  • Display Analytics
    • Google Analytics
  • Display JavaScript API
    • Quick Start
    • Commands
    • Events
  • Flipbook Analytics
    • Adobe Analytics events
    • Google Analytics / GTM events
  • Flipbook Backend API
    • Overview
    • Return Codes
    • Ecommerce
      • GetFlipbookOrdersByType
      • GetLicenseOrdersByType
    • Image
      • GetImageWith2PxDropShadow
    • Link
      • GetLinks
    • Media
      • CreateDirectory
      • DeleteDirectory
      • DeleteFile
      • GetTree
      • UploadFile
    • Paper
      • ChangePaperUrl
      • ClearPublicationPeriod
      • CreateCategory
      • CreatePaper
      • CreatePreviewToken
      • DeletePaper
      • GetAllPapers
      • GetPaperIDFromUrl
      • GetPaperStructure
      • GetPaperUrlFromID
      • GetSetting
      • GetSettingDescriptions
      • MovePaper
      • SetPublicationPeriod
      • SetSetting
    • Ripper
      • GetProcessingPapers
      • GetProcessingStatus
      • ProcessPDF
      • ReprocessPaper
    • Search
      • SearchPapersByContent
      • SearchPapersByCustomFields
      • SearchPapersWithHiearchyByContent
      • SearchPapersWithHiearchyByName
    • Statistics
      • GetNumberOfPageviewsPerDay
      • GetNumberOfVisitors
      • GetNumberOfVisitorsPerDay
  • Flipbook Enrichment
    • Popup Content
    • Popup Frame
  • Flipbook Integration
    • Custom Domain
    • Custom Mail
    • Embedding flipbooks inside iOS and Android App
    • Form Integration
    • Iframing Flipbooks
    • iPaper Embed Script (Pop-ups)
    • Embeds (Minipapers)
    • Query String Parameters
    • Remote Authentication
    • Shop Export
  • Flipbook JavaScript API
    • Getting Started
    • Commands & Events
      • Basket
      • Consent
        • Example Implementations
          • UserCentrics
          • OneTrust
          • CookieInformation
          • Cookiebot
      • Paging
      • Publication
      • Search
      • Table of Contents
      • Sharing
    • Advanced Usage
    • Migration guide
    • Legacy Javascript API (v2)
      • Quick Start
      • Commands
      • Events
      • Consent Management
      • Advanced Usage
  • Technical Information
    • Cookie Information
    • Common security questions
    • Open Source
Powered by GitBook
On this page
  • Commands
  • open
  • close
  • getState
  • addProduct
  • Events
  • onOpened
  • onClosed
  • onToggled
  • onProductAdd
  1. Flipbook JavaScript API
  2. Commands & Events

Basket

Commands

open

Opens the basket.

instance.basket.open();

close

Closes the basket.

instance.basket.close();

getState

Gets the current state of the basket.

// You can either await the result of the command
const result = await instance.basket.getState();

// OR pass a callback
instance.basket.getState((result) => {
    // YOUR CODE HERE
});

The command will return an object with the following properties:

Property
Type
Description

isOpen

boolean

Is the basket currently open

addProduct

Adds a product to the basket. The command accepts a single argument, consisting of the properties below:

Property
Type
Description

title

string

Product title

description

string

Product description

productId

string

Product Id

price

number

Product price

originPage

number

Page where the product is located on

quantity

number

Quanity of product to add

Below is an example use:

instance.basket.addProduct({
    title: 'My product',
    description: 'Product description',
    productId: 'PROD-25B',
    price: '29.95',
    originPage: 6,
    quantity: 1
});

Events

onOpened

This subscription will trigger every time the basket is opened.

instance.basket.onOpened(() => {
    // YOUR CODE HERE
});

onClosed

This subscription will trigger every time the basket is closed.

instance.basket.onClosed(() => {
    // YOUR CODE HERE
});

onToggled

This subscription will trigger every time the basket is toggled between open and closed state.

instance.basket.onToggled(() => {
    // YOUR CODE HERE
});

onProductAdd

This subscription will trigger whenever a product is added to the basket.

Note:

Products added through the addProduct API command will not trigger this subscription.

instance.basket.onProductAdd((product) => {
    // YOUR CODE HERE
});

The callback contains a value/result of the product that was added, containing the following properties:

Property
Type
Description

title

string

Product title

description

string

Product description

productId

string

Product ID

price

number

Product price

pageIndex

number

Page index where the product is located* (see note)

originPage

number

Page where the product is located on

quantity

number

Quanity of product added

packageSize

number

Number of items per package

Note:

Please note that pageIndex starts at 0. So the 1st page of your flipbook will have a pageIndex of 0, page 2 a pageIndex of 1 and so on. To get the actual pagenumber you should use originPage instead.

PreviousCommands & EventsNextConsent

Last updated 1 month ago