Rokt Documentation
  • Documentation
  • User Guide
  • SDK
  • API
  • Third-Party Integrations
  • Help

›Interfaces

Getting Started

  • Introduction

Web SDK

  • Overview
  • Architecture
  • Integrating the Web SDK
  • Integration Examples

    • Confirmation Page Integration
    • Preparative Iframe
    • Page Identifier
    • Single Page Applications
    • Brand Conversion Integration
    • In Transaction/Cart Integration
    • Event-based Integration
    • Sandbox Integration
  • Integration Best Practices
  • Attributes
  • Security
  • Mobile In-App Web Pages
  • API

    • README
    • Globals

    Enumerations

    • FailureReason

    Interfaces

    • Attributes
    • Cart
    • CartItem
    • PlacementCloseEvent
    • Rokt
    • RoktConfiguration
    • Widget

iOS SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration
  • Attributes
  • Security

Android SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration

    Attributes

    • Core Attributes
    • Vertical Attributes
  • Security

React Native SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration

    Attributes

    • Core Attributes
    • Vertical Attributes
  • Security
Edit

Cart

Provides an interface to interact with cart state on the Rokt side.

see Cart.onUpdateItem on how to be informed about item changes triggered on Rokt side.

see Cart.setItems on how to set state of the cart.

Methods

getItems

▸ getItems(): ReadonlyArray‹CartItem›

Creates and returns a copy of the current state of Rokt cart. Each time the method is invoked a new copy is created.

Returns: ReadonlyArray‹CartItem›


onUpdateItem

▸ onUpdateItem(updateItemCallback: function): void

Accepts a callback method to be triggered by Rokt whenever user updates an item in cart. The updated item state and the old item states are passed as a parameter to the callback method.

In case of user adding item to the cart for the first time old item state will be null. The same if user removes previously chosen item updatedItem will be null.

example

rokt.cart.updateItemCallback((updatedItem, oldItem) => {
  // client logic to update cart state on client side
});

Parameters:

▪ updateItemCallback: function

Update item callback

▸ (updatedItem: CartItem | null, oldItem: CartItem | null): void

Parameters:

NameType
updatedItemCartItem | null
oldItemCartItem | null

Returns: void


setItems

▸ setItems(items: Array‹CartItem›): void

Method used to set state of the cart on Rokt side. Useful during subsequent visits to a page where Rokt offers are displayed in order to initialise state of a cart based on current state hold on client side.

example

rokt.cart.setItems(cartItems);

Parameters:

NameTypeDescription
itemsArray‹CartItem›An array of cart items.

Returns: void

← AttributesCartItem →
  • Methods
    • getItems
    • onUpdateItem
    • setItems
RESOURCES
DocumentationUser GuideSDKAPIIntegration PartnersHelp
COMPANY
About UsContact UsCareersEngineering Blog
Rokt Documentation
Copyright © Rokt 2021 - All Rights Reserved